Debian Codegraph @

benchmarks.larceny/src/takl.scm

raw
1 ;;; TAKL -- The TAKeuchi function using lists as counters.
2
3 (define (listn n)
4 (if (= n 0)
5 '()
6 (cons n (listn (- n 1)))))
7
8 (define l18 (listn 18))
9 (define l12 (listn 12))
10 (define l6 (listn 6))
11
12 (define (mas x y z)
13 (if (not (shorterp y x))
14 z
15 (mas (mas (cdr x) y z)
16 (mas (cdr y) z x)
17 (mas (cdr z) x y))))
18
19 (define (shorterp x y)
20 (and (not (null? y))
21 (or (null? x)
22 (shorterp (cdr x)
23 (cdr y)))))
24
25 (define (main . args)
26 (run-benchmark
27 "takl"
28 takl-iters
29 (lambda (result) (equal? result '(7 6 5 4 3 2 1)))
30 (lambda (x y z) (lambda () (mas x y z)))
31 l18
32 l12
33 l6))