diff options
author | rsiddharth <s@ricketyspace.net> | 2017-07-01 23:40:14 +0000 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2017-07-01 23:40:14 +0000 |
commit | d022481e3c3e9337e22b9d92bf805065bd64d05f (patch) | |
tree | fbd6cc44794d5f6f3db823d7076703f569baf4de | |
parent | 20de4932b291ebd0a24e6fcf5152f972bd80d4e9 (diff) |
(net ricketyspace sicp one twentytwo): Add three-primes-gt.
* net/ricketyspace/sicp/one/twentytwo.scm (three-primes-gt)
(three-primes-gt-iter): New functions.
-rw-r--r-- | net/ricketyspace/sicp/one/twentytwo.scm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/net/ricketyspace/sicp/one/twentytwo.scm b/net/ricketyspace/sicp/one/twentytwo.scm index 209afaf..7eab420 100644 --- a/net/ricketyspace/sicp/one/twentytwo.scm +++ b/net/ricketyspace/sicp/one/twentytwo.scm @@ -4,8 +4,10 @@ (define-module (net ricketyspace sicp one twentytwo) #:use-module (net ricketyspace sicp utils) + #:use-module (srfi srfi-1) #:export (timed-prime-test - search-for-primes)) + search-for-primes + three-primes-gt)) (define (square x) (expt x 2)) @@ -46,3 +48,12 @@ ((odd-and-prime start) (cons start (search-for-primes (1+ start) end))) (else (search-for-primes (1+ start) end)))) + +(define (three-primes-gt n) + (three-primes-gt-iter n 10 '())) + +(define (three-primes-gt-iter n e l) + (cond ((> (length l) 3) (take l 3)) + (else (three-primes-gt-iter n + (+ e 10) + (search-for-primes n e))))) |