aboutsummaryrefslogtreecommitdiff
path: root/src/lisp/std.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lisp/std.lisp')
-rw-r--r--src/lisp/std.lisp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/lisp/std.lisp b/src/lisp/std.lisp
index 2a042a0..6c5beed 100644
--- a/src/lisp/std.lisp
+++ b/src/lisp/std.lisp
@@ -9,6 +9,18 @@
9(define (cdddddr ls) (cdr (cddddr ls))) 9(define (cdddddr ls) (cdr (cddddr ls)))
10 10
11(define (null? ls) (eq? ls '())) 11(define (null? ls) (eq? ls '()))
12(define (zero? x) (eq? x 0))
13
14(define (remainder x y)
15 (if (> y x)
16 x
17 (remainder (- x y) y)))
18
19(define (quotient x y)
20 (/ x y))
21
22(define (even? x) (zero? (remainder x 2)))
23(define (odd? x) (not (even? x)))
12 24
13(define (length ls) 25(define (length ls)
14 (if (null? ls) 26 (if (null? ls)
@@ -45,9 +57,3 @@
45 57
46(define (sum ls) (fold 0 + ls)) 58(define (sum ls) (fold 0 + ls))
47(define (product ls) (fold 1 * ls)) 59(define (product ls) (fold 1 * ls))
48
49(define (enumerate start stop step)
50 (if (>= start stop)
51 '()
52 (cons start
53 (enumerate (+ start step) stop step))))