Move array functions out of global scope
This commit is contained in:
parent
c33d8e5d38
commit
76b1f987a2
|
@ -1,7 +1,19 @@
|
|||
(defmacro array (length)
|
||||
(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)
|
||||
(let* ((this (gensym))
|
||||
(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)))
|
||||
|
||||
`(let ,index-bindings
|
||||
|
@ -28,13 +40,4 @@
|
|||
(call ,this :get (first indices))
|
||||
accumulator))))
|
||||
(reverse ',indices)
|
||||
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))))
|
||||
nil))))))))
|
||||
|
|
Loading…
Reference in New Issue