diff options
Diffstat (limited to 'guile')
-rw-r--r-- | guile/taocp/one/two/eight/fib.scm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/guile/taocp/one/two/eight/fib.scm b/guile/taocp/one/two/eight/fib.scm index cbdbbc7..80e4784 100644 --- a/guile/taocp/one/two/eight/fib.scm +++ b/guile/taocp/one/two/eight/fib.scm @@ -24,6 +24,14 @@ '() (iota 1000 0)))) +(define (fib-fast-range start end) + "Return Fibonacci series between START and END." + (let ((count (1+ (- end start)))) + (reverse (fold (lambda (n prev) + (cons (fib-fast n) prev)) + '() + (iota count start))))) + ;; scheme@(taocp one two eight fib)> (fib-1-1000) ;; $39 = (0.0 1.0 1.0 2.0 3.0 5.0 8.0 13.0 21.0 34.0 54.99999999999999 |