scm.mes: add expt.
This commit is contained in:
parent
9fc7868a6d
commit
bbdba26201
5
scm.mes
5
scm.mes
|
@ -185,6 +185,11 @@
|
||||||
(define (remainder x y)
|
(define (remainder x y)
|
||||||
(- x (* (/ x y) 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)
|
(define (max x . rest)
|
||||||
(if (null? rest) x
|
(if (null? rest) x
|
||||||
(let* ((y (car rest))
|
(let* ((y (car rest))
|
||||||
|
|
1
test.mes
1
test.mes
|
@ -104,6 +104,7 @@
|
||||||
(pass-if "/" (seq? (/ 9 3) 3))
|
(pass-if "/" (seq? (/ 9 3) 3))
|
||||||
(pass-if "remainder" (seq? (remainder 11 3) 2))
|
(pass-if "remainder" (seq? (remainder 11 3) 2))
|
||||||
(pass-if "modulo" (seq? (modulo 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 "=" (seq? 3 '3))
|
||||||
(pass-if "= 2" (not (= 3 '4)))
|
(pass-if "= 2" (not (= 3 '4)))
|
||||||
|
|
Loading…
Reference in a new issue