2007-06-13 03:19:16 -04:00
|
|
|
;;; ACK -- One of the Kernighan and Van Wyk benchmarks.
|
|
|
|
|
2007-11-04 12:03:32 -05:00
|
|
|
(library (rnrs-benchmarks ack)
|
2007-06-13 03:19:16 -04:00
|
|
|
(export main)
|
2007-11-04 12:03:32 -05:00
|
|
|
(import (rnrs) (rnrs-benchmarks))
|
2007-06-13 03:19:16 -04:00
|
|
|
|
|
|
|
(define (ack m n)
|
|
|
|
(cond ((= m 0) (+ n 1))
|
|
|
|
((= n 0) (ack (- m 1) 1))
|
|
|
|
(else (ack (- m 1) (ack m (- n 1))))))
|
|
|
|
|
|
|
|
(define (main . args)
|
|
|
|
(run-benchmark
|
|
|
|
"ack"
|
|
|
|
ack-iters
|
|
|
|
(lambda (result) (equal? result 4093))
|
|
|
|
(lambda (m n) (lambda () (ack m n)))
|
|
|
|
3
|
|
|
|
9)))
|