24 lines
486 B
Scheme
24 lines
486 B
Scheme
;;; TAK -- A vanilla version of the TAKeuchi function.
|
|
|
|
|
|
(library (rnrs-benchmarks tak)
|
|
(export main)
|
|
(import (rnrs) (rnrs-benchmarks))
|
|
|
|
(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)))
|