21 lines
414 B
Scheme
21 lines
414 B
Scheme
|
;;; FIB -- A classic benchmark, computes fib(35) inefficiently.
|
||
|
|
||
|
(library (r6rs-benchmarks fib)
|
||
|
(export main)
|
||
|
(import (r6rs) (r6rs-benchmarks))
|
||
|
|
||
|
(define (fib n)
|
||
|
(if (< n 2)
|
||
|
n
|
||
|
(+ (fib (- n 1))
|
||
|
(fib (- n 2)))))
|
||
|
|
||
|
(define (main . args)
|
||
|
(run-benchmark
|
||
|
"fib"
|
||
|
fib-iters
|
||
|
(lambda (result) (equal? result 9227465))
|
||
|
(lambda (n) (lambda () (fib n)))
|
||
|
35)))
|
||
|
|