2007-06-13 10:49:54 -04:00
|
|
|
;;; TAK -- A vanilla version of the TAKeuchi function.
|
|
|
|
|
|
|
|
|
2007-11-04 12:03:32 -05:00
|
|
|
(library (rnrs-benchmarks tak)
|
2007-06-13 10:49:54 -04:00
|
|
|
(export main)
|
2007-11-04 12:03:32 -05:00
|
|
|
(import (rnrs) (rnrs-benchmarks))
|
2007-06-13 10:49:54 -04:00
|
|
|
|
|
|
|
(define (tak x y z)
|
|
|
|
(if (not (< y x))
|
|
|
|
z
|
|
|
|
(tak (tak (- x 1) y z)
|
|
|
|
(tak (- y 1) z x)
|
|
|
|
(tak (- z 1) x y))))
|
|
|
|
|
|
|
|
(define (main . args)
|
|
|
|
(run-benchmark
|
|
|
|
"tak"
|
|
|
|
tak-iters
|
|
|
|
(lambda (result) (equal? result 7))
|
|
|
|
(lambda (x y z) (lambda () (tak x y z)))
|
|
|
|
18
|
|
|
|
12
|
|
|
|
6)))
|