(defun array2list (a) (let (l) (dotimes (i (length a) (reverse l)) (push (aref a i) l)))) (defmacro doarrayi ((one n array &optional out) &body body) (let ((i (gensym))) `(let ((,i (length ,array))) (dotimes (,n ,i ,out) (let ((,one (aref ,array ,n))) ,@body))))) (defmacro doarray ((one array &optional out) &body body) (let ((j (gensym))) `(doarrayi (,one ,j ,array ,out) ,@body))) ;(deftest test-do-array () ; (let* ((count 0) ; (r1 (doarrayi (x i #(0 1 2) count) ; (incf count x) ; (incf count i))) ; (r2 (doarray (x #(0 1 2) count) ; (incf count x)))) ; (check ; (= r1 6) ; (= r2 9)));)