Debian Codegraph @

benchmarks.larceny/src/sumloop.scm

raw
1 ;;; SUMLOOP -- One of the Kernighan and Van Wyk benchmarks.
2
3 (define sum 0)
4
5 (define (tail-rec-aux i n)
6 (if (< i n)
7 (begin (set! sum (+ sum 1)) (tail-rec-aux (+ i 1) n))
8 sum))
9
10 (define (tail-rec-loop n)
11 (set! sum 0)
12 (tail-rec-aux 0 n)
13 sum)
14
15 (define (do-loop n)
16 (set! sum 0)
17 (do ((i 0 (+ i 1)))
18 ((>= i n) sum)
19 (set! sum (+ sum 1))))
20
21 (define (main . args)
22 (run-benchmark
23 "sumloop"
24 sumloop-iters
25 (lambda (result) (equal? result 100000000))
26 (lambda (n) (lambda () (do-loop n)))
27 100000000))