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.lisp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lisp/std.lisp b/src/lisp/std.lisp
index c723a13..8350482 100644
--- a/src/lisp/std.lisp
+++ b/src/lisp/std.lisp
@@ -22,5 +22,27 @@
22 accumulator 22 accumulator
23 (cdr ls)))) 23 (cdr ls))))
24 24
25(define (map func ls)
26 (if (null? ls)
27 '()
28 (cons (func (car ls))
29 (map func (cdr ls)))))
30
31(define (filter pred ls)
32 (if (null? ls)
33 '()
34 (if (pred (car ls))
35 (cons (car ls) (filter pred (cdr ls)))
36 (filter pred (cdr ls)))))
37
38(define (member? item ls)
39 (if (null? ls)
40 #f
41 (or (eq? item (car ls))
42 (member? item (cdr ls)))))
43
44(define (assert expr)
45 (assert-eq #t expr))
46
25(define (sum ls) (fold 0 + ls)) 47(define (sum ls) (fold 0 + ls))
26(define (product ls) (fold 1 * ls)) 48(define (product ls) (fold 1 * ls))