| 1 |
;;; DIVITER -- Benchmark which divides by 2 using lists of n ()'s. |
| 2 |
|
| 3 |
(library (rnrs-benchmarks diviter) |
| 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 (iterative-div2 l) |
| 15 |
(do ((l l (cddr l)) |
| 16 |
(a '() (cons (car l) a))) |
| 17 |
((null? l) a))) |
| 18 |
|
| 19 |
(define (main . args) |
| 20 |
(run-benchmark |
| 21 |
"diviter" |
| 22 |
diviter-iters |
| 23 |
(lambda (result) |
| 24 |
(equal? result |
| 25 |
'(() () () () () () () () () () () () () () () () () () () () |
| 26 |
() () () () () () () () () () () () () () () () () () () () |
| 27 |
() () () () () () () () () () () () () () () () () () () () |
| 28 |
() () () () () () () () () () () () () () () () () () () () |
| 29 |
() () () () () () () () () () () () () () () () () () () ()))) |
| 30 |
(lambda (l) (lambda () (iterative-div2 l))) |
| 31 |
*ll*))) |