Name: Anonymous 2011-03-24 7:19
Lets face it /prog/, I'm a shitty programmer.
How would you improve upon these functions?
It's a couple of functions I was gonna use for writing a primes function utilizing the sieve of Erastothenes.
How would you improve upon these functions?
It's a couple of functions I was gonna use for writing a primes function utilizing the sieve of Erastothenes.
(defun make-prime-array (n)
(let ((output (make-array (1- n))))
(loop for i from 2 to n do
(setf (aref output (- i 2)) i))
output))
(defun clean-array (arr n )
(let ((output nil))
(loop for i across arr do
(if (/= (mod i n) 0)
(push i output))
(if (= i n)
(push i output)))
(reverse output)))
(defun make-array-list (lst)
(let ((output (make-array (length lst))))
(loop for i from 0 to (1- (length lst)) do
(setf (aref output i) (nth i lst)))
output))