SICP/util.scm

17 lines
323 B
Scheme
Raw Normal View History

2020-10-20 03:36:17 +02:00
(define (assert a b)
(cond ((equal? a b) (display "[ok]"))
(else
(display "[error] ")
(display a)
(display " != ")
(display b)))
(newline))
(define (gcd a b)
(if (= b 0) (abs a) (gcd b (remainder a b))))
2020-10-24 17:24:13 +02:00
(define (average a b) (/ (+ a b) 2.0))
2020-10-26 02:40:51 +01:00
(define (id n) n)
(define (inc n) (+ n 1))
2020-10-24 17:24:13 +02:00