Post Scarcity
A prototype for a post scarcity programming environment
Loading...
Searching...
No Matches
defun.lisp
Go to the documentation of this file.
1(set! symbol? (lambda (x) (equal (type x) "SYMB")))
2
3(set! defun!
4 (nlambda
5 "`(defun name arg-list forms...)`: Define an interpreted Lambda function with this `name` and this `arg-list`, whose body is comprised of these `forms`."
6 form
7 (eval (list 'set! (car form) (cons 'lambda (cdr form))))))
8
9(defun! square (x) (* x x))
10
11(set! defsp!
12 (nlambda
13 form
14 (cond (symbol? (car form))
15 (set! (car form) (apply nlambda (cdr form))))))
16
17(defun! cube (x) (* x x x))
18
19(set! p 5)
20
21(square 5) ;; should work
22
23(square p) ;; should work
24
25(cube 5) ;; should work
26
27(cube p) ;; should fail: unbound symbol