diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:06:40 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:06:40 -0800 |
commit | a69c9fb665459e2bfdbda1bf80741a0af31a7faf (patch) | |
tree | f0bc974f8805049e6b9a4e6864886298fbaa05a4 /sort.scm | |
parent | 4684239efa63dc1b2c1cbe37ef7d3062029f5532 (diff) | |
download | slib-a69c9fb665459e2bfdbda1bf80741a0af31a7faf.tar.gz slib-a69c9fb665459e2bfdbda1bf80741a0af31a7faf.zip |
New upstream version 3b5upstream/3b5upstream
Diffstat (limited to 'sort.scm')
-rwxr-xr-x[-rw-r--r--] | sort.scm | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -16,6 +16,7 @@ ;;; jaffer: 2007-01-29: Final SRFI-95. (require 'array) +(require 'multiarg-apply) ; used in SORT ;;; (sorted? sequence less?) ;;; is true when sequence is a list (x0 x1 ... xm) or a vector #(x0 ... xm) @@ -157,12 +158,11 @@ (define (sort! seq less? . opt-key) (define key (if (null? opt-key) #f (car opt-key))) (cond ((array? seq) - (let ((dims (array-dimensions seq))) - (do ((sorted (sort:sort-list! (rank-1-array->list seq) less? key) - (cdr sorted)) - (i 0 (+ i 1))) - ((null? sorted) seq) - (array-set! seq (car sorted) i)))) + (do ((sorted (sort:sort-list! (rank-1-array->list seq) less? key) + (cdr sorted)) + (i 0 (+ i 1))) + ((null? sorted) seq) + (array-set! seq (car sorted) i))) (else ; otherwise, assume it is a list (let ((ret (sort:sort-list! seq less? key))) (if (not (eq? ret seq)) @@ -184,8 +184,7 @@ (define (sort seq less? . opt-key) (define key (if (null? opt-key) #f (car opt-key))) (cond ((array? seq) - (let ((dims (array-dimensions seq))) - (define newra (apply make-array seq dims)) + (let ((newra (apply make-array seq (array-dimensions seq)))) (do ((sorted (sort:sort-list! (rank-1-array->list seq) less? key) (cdr sorted)) (i 0 (+ i 1))) |