scm.mes: add expt.

This commit is contained in:
Jan Nieuwenhuizen 2016-07-24 17:16:55 +02:00
parent 9fc7868a6d
commit bbdba26201
2 changed files with 6 additions and 0 deletions

View file

@ -185,6 +185,11 @@
(define (remainder x y)
(- x (* (/ x y) y)))
(define (expt x y)
(let loop ((s 1) (count y))
(if (= 0 count) s
(loop (* s x) (- count 1)))))
(define (max x . rest)
(if (null? rest) x
(let* ((y (car rest))

View file

@ -104,6 +104,7 @@
(pass-if "/" (seq? (/ 9 3) 3))
(pass-if "remainder" (seq? (remainder 11 3) 2))
(pass-if "modulo" (seq? (modulo 11 3) 2))
(pass-if "expt" (seq? (expt 2 3) 8))
(pass-if "=" (seq? 3 '3))
(pass-if "= 2" (not (= 3 '4)))