From 737502c4de08366fd076a65f3a3a6b8926a8b913 Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Sat, 10 Feb 2018 12:27:23 -0500 Subject: [PATCH] Stop array from creating global symbol --- lisp/random/array.lisp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) 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))))))))