#
# primes
# By Ozan Yigit
#
eval (define  (interval-list m n) \
  (if (> m n) \
      '() \
      (cons m (interval-list (+ 1 m) n))))

eval (define (sieve l) \
  (define (remove-multiples n l) \
    (if (null? l) \
	'() \
	(if  (= (modulo (car l) n) 0) \
	     (remove-multiples n (cdr l)) \
	     (cons (car l) \
		   (remove-multiples n (cdr l)))))) \
  (if (null? l) \
      '() \
      (cons (car l) \
	    (sieve (remove-multiples (car l) (cdr l))))))

eval (define (primes<= n) (sieve (interval-list 2 n)))
#
# Sib-pair interface
#
macro primes
  eval (primes<= %1)
;;;;
