/usr/lib/sieve.scm is in scheme9 2013.11.26-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2010
; Placed in the Public Domain
;
; (sieve integer) ==> list
;
; Given an INTEGER N, generate a list of all prime numbers less
; than N. INTEGER must be positive.
;
; Example: (sieve 20) ==> (2 3 5 7 11 13 17 19)
(define (sieve n)
(letrec
((sieve2
(lambda (n primes)
(let loop ((p (reverse primes)))
(cond ((or (null? p)
(> (* (car p) (car p)) n))
(cons n primes))
((zero? (remainder n (car p)))
primes)
(else
(loop (cdr p))))))))
(let loop ((i 3)
(primes (list 2)))
(if (> i n)
(reverse! primes)
(loop (+ 2 i) (sieve2 i primes))))))
|