27 lines
609 B
Scheme
27 lines
609 B
Scheme
;;; SUM -- Compute sum of integers from 0 to 10000
|
|
|
|
(import (scheme base)
|
|
(scheme read)
|
|
(scheme write))
|
|
|
|
(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-r7rs-benchmark
|
|
(string-append name ":" s1 ":" s2)
|
|
count
|
|
(lambda () (run (hide count input1)))
|
|
(lambda (result) (equal? result output)))))
|
|
|
|
(include "src/common.sch")
|