summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2019-11-26 17:28:06 +0100
committertomsmeding <tom.smeding@gmail.com>2019-11-26 17:28:06 +0100
commitb51fdba5613d9a61a7a1e9a38b366fdf56a0b11f (patch)
treed48cf15cfec00942a19f873386df9f4883acfc8b
parent5f86130930c19277fbf0ef3433cc43ab93aacf3f (diff)
stdlib: const, ., reverse
-rw-r--r--tests/stdlib.lisp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/stdlib.lisp b/tests/stdlib.lisp
index 86dabe2..88af2a1 100644
--- a/tests/stdlib.lisp
+++ b/tests/stdlib.lisp
@@ -6,11 +6,15 @@
(define or (x y) (if x 1 (if y 1 0)))
(define and (x y) (if x (if y 1 0) 0))
+(define const (x) (lambda (_) x))
+
(define != (x y) (not (= x y)))
(define < (x y) (and (<= x y) (!= x y)))
(define > (x y) (< y x))
(define >= (x y) (<= y x))
+(define . (f g) (lambda (x) (f (g x))))
+
(define YY (recur) (lambda (f) (lambda (a) (f ((recur recur) f) a))))
(define Y (YY YY))
@@ -76,6 +80,12 @@
(define all (generic-list-string-2 "all" all-list all-str))
+(define reverse (l)
+ (let ((helper (lambdarec rec (l2 rest)
+ (if (null? l2) rest
+ (rec (cdr l2) (cons (car l2) rest))))))
+ (helper l '())))
+
(define stdin (sys-stdin))
(define stdout (sys-stdout))
(define stderr (sys-stderr))