; Performs the sieve of Eratosthenes over a list of numbers. ; Further explanation is contained on the zlisp documentation page zlispdoc.html ; Alejandro Luque Estepa, 1999 (defun divisible (n m) (zerop (mod n m))) (defun cribe (list) (subset '(lambda (x) (not (divisible x (car list)))) (cdr list))) (defun sieve (list) (cond ((null list) nil) (t (cons (car list) (sieve (cribe list)))) ) ) (defun numbers (n m) (do ((i m (sub1 i)) (l nil (cons i l))) ((! (> i n)) l)) ) (msg "Usage: (sieve list), where list is a set of numers over wich" t "you want to perform the sieve of Erathostenes." t "(numbers n m) returns a list of all integer numbers between n and m," t " so (sieve (numbers 2 100)) will return a list of all prime numbers below 100")