-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.mlisp
49 lines (35 loc) · 1.03 KB
/
test.mlisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(defun fact (n)
(if (= 0 n)
1
(* n (fact (- n 1)))))
(defun add-5 (a) (+ a 5))
(defun even? (a) (= 0 (mod a 2)))
(def numbersl '(1 2 3 4 5 6 7 8 9 10))
(defun call (a) (a))
(defun lazy-range (start stop)
(if (= start stop) nil
(fun () (cons start (lazy-range (+ start 1) stop)))))
(defun take-inner (n lst acc)
(cond
(= 0 n) acc
(nil? lst) acc
(fun? lst) (take-inner n (lst) acc)
(fun? (hd lst)) (take-inner
(- n 1)
(tail lst)
(cons ((hd lst)) acc))
true (take-inner (- n 1) (tail lst) (cons (hd lst) acc))))
(defun take (n lst) (rev (take-inner n lst nil)))
(defun not (b) (if b false true))
(defun and (a b) (if a b (false)))
(defun or (a b) (if a true b))
(defun xor (a b) (if a (not b) b))
(defun nand (a b) (not (and a b)))
(defun add-twice-squared (a)
(let (squared (* a a))
(do
(io-puts squared)
(+ squared squared))))
(def myrange (lazy-range 0 1000000000))
(deftrait ooga (
(defun do-something (x y))))