24 lines
559 B
Plaintext
24 lines
559 B
Plaintext
|
;;; SUM -- Compute sum of integers from 0 to 10000
|
||
|
|
||
|
(import (rnrs base)
|
||
|
(rnrs io simple))
|
||
|
|
||
|
(define (run n)
|
||
|
(let loop ((i n) (sum 0))
|
||
|
(if (< i 0)
|
||
|
sum
|
||
|
(loop (- i 1) (+ i sum)))))
|
||
|
|
||
|
(define (main)
|
||
|
(let* ((count (read))
|
||
|
(input1 (read))
|
||
|
(output (read))
|
||
|
(s2 (number->string count))
|
||
|
(s1 (number->string input1))
|
||
|
(name "sum"))
|
||
|
(run-r6rs-benchmark
|
||
|
(string-append name ":" s1 ":" s2)
|
||
|
count
|
||
|
(lambda () (run (hide count input1)))
|
||
|
(lambda (result) (equal? result output)))))
|