14 lines
405 B
Common Lisp
14 lines
405 B
Common Lisp
(defmacro array (size)
|
|
`(let ,(map (lambda (x) (list (fuse 'index x))) (create-indices size))
|
|
(dlambda
|
|
(:get (i) (eval (fuse 'index i)))
|
|
(:set (i value) (set (fuse 'index i) value)))))
|
|
|
|
(defun create-indices (size)
|
|
(create-indices-tail (- size 1) ()))
|
|
|
|
(defun create-indices-tail (index accumulator)
|
|
(if (< index 0)
|
|
accumulator
|
|
(recur (- index 1) (cons index accumulator))))
|