Move array functions out of global scope
This commit is contained in:
parent
c33d8e5d38
commit
76b1f987a2
|
@ -1,7 +1,19 @@
|
||||||
|
(let ((static))
|
||||||
|
|
||||||
|
(setq static
|
||||||
|
(dlambda
|
||||||
|
(:create-indices (length)
|
||||||
|
(call static :create-indices-tail (- length 1) ()))
|
||||||
|
|
||||||
|
(:create-indices-tail (index accumulator)
|
||||||
|
(if (< index 0)
|
||||||
|
accumulator
|
||||||
|
(recur (- index 1) (cons index accumulator))))))
|
||||||
|
|
||||||
(defmacro array (length)
|
(defmacro array (length)
|
||||||
(let* ((this (gensym))
|
(let* ((this (gensym))
|
||||||
(index-prefix (fuse this 'index))
|
(index-prefix (fuse this 'index))
|
||||||
(indices (create-indices length))
|
(indices (call static :create-indices length))
|
||||||
(index-bindings (map (lambda (i) (list (fuse index-prefix i))) indices)))
|
(index-bindings (map (lambda (i) (list (fuse index-prefix i))) indices)))
|
||||||
|
|
||||||
`(let ,index-bindings
|
`(let ,index-bindings
|
||||||
|
@ -28,13 +40,4 @@
|
||||||
(call ,this :get (first indices))
|
(call ,this :get (first indices))
|
||||||
accumulator))))
|
accumulator))))
|
||||||
(reverse ',indices)
|
(reverse ',indices)
|
||||||
nil)))))))
|
nil))))))))
|
||||||
|
|
||||||
|
|
||||||
(defun create-indices (length)
|
|
||||||
(create-indices-tail (- length 1) ()))
|
|
||||||
|
|
||||||
(defun create-indices-tail (index accumulator)
|
|
||||||
(if (< index 0)
|
|
||||||
accumulator
|
|
||||||
(recur (- index 1) (cons index accumulator))))
|
|
||||||
|
|
Loading…
Reference in New Issue