diff --git a/lisp/random/array.lisp b/lisp/random/array.lisp index 92f23a8..6532fc0 100644 --- a/lisp/random/array.lisp +++ b/lisp/random/array.lisp @@ -14,9 +14,10 @@ (let* ((this (gensym)) (index-prefix (fuse this 'index)) (indices (call static :create-indices length)) - (index-bindings (map (lambda (i) (list (fuse index-prefix i))) indices))) + (index-bindings (map (lambda (i) `(,(fuse index-prefix i))) indices)) + (scope `((,this) ,@index-bindings))) - `(let ,index-bindings + `(let ,scope (setq ,this (dlambda (:get (i) @@ -31,13 +32,10 @@ ,length) (t () - ((lambda (indices accumulator) - (if (null? indices) + ((lambda (length accumulator) + (if (< length 1) accumulator (recur - (rest indices) - (cons - (call ,this :get (first indices)) - accumulator)))) - (reverse ',indices) - nil)))))))) + (- length 1) + (cons (call ,this :get (- length 1)) accumulator)))) + ,length nil))))))))