Debian Codegraph @

benchmarks/rnrs-benchmarks/divrec.ss

raw
1 ;;; DIVREC -- Benchmark which divides by 2 using lists of n ()'s.
2
3 (library (rnrs-benchmarks divrec)
4 (export main)
5 (import (rnrs) (rnrs-benchmarks))
6
7 (define (create-n n)
8 (do ((n n (- n 1))
9 (a '() (cons '() a)))
10 ((= n 0) a)))
11
12 (define *ll* (create-n 200))
13
14 (define (recursive-div2 l)
15 (cond ((null? l) '())
16 (else (cons (car l) (recursive-div2 (cddr l))))))
17
18 (define (main . args)
19 (run-benchmark
20 "divrec"
21 divrec-iters
22 (lambda (result)
23 (equal? result
24 '(() () () () () () () () () () () () () () () () () () () ()
25 () () () () () () () () () () () () () () () () () () () ()
26 () () () () () () () () () () () () () () () () () () () ()
27 () () () () () () () () () () () () () () () () () () () ()
28 () () () () () () () () () () () () () () () () () () () ())))
29 (lambda (l) (lambda () (recursive-div2 l)))
30 *ll*)))