2011-10-01から1ヶ月間の記事一覧

Gaucheで素数ストリーム

エラトステネスの篩 (define (divisor? x y) (eqv? 0 (remainder x y))) (define-constant +primes+ (stream-cons 2 (stream-filter prime? (stream-iota -1 3 2)))) ;; (define (prime? n) ;; (not (stream-any (cut divisor? n <>) (stream-take-while (cu…