add def implementation for lambdas
This commit is contained in:
parent
950716f2f3
commit
15f1e6a2b1
@ -35,7 +35,7 @@ function Lisp (input, lib) {
|
|||||||
return interpret(input[2], letContext)
|
return interpret(input[2], letContext)
|
||||||
},
|
},
|
||||||
def: function (input, context) {
|
def: function (input, context) {
|
||||||
context.scope[input[1].value] = input[2].value
|
context.scope[input[1].value] = interpret(input[2], context)
|
||||||
return input[2]
|
return input[2]
|
||||||
},
|
},
|
||||||
lambda: function (input, context) {
|
lambda: function (input, context) {
|
||||||
|
@ -41,5 +41,7 @@
|
|||||||
; Scope
|
; Scope
|
||||||
|
|
||||||
(def aaa 123)
|
(def aaa 123)
|
||||||
(test "def" aaa 123)
|
(def addOne (lambda (a) (add a 1)))
|
||||||
|
(test "def - value" aaa 123)
|
||||||
|
(test "def - func" (addOne 4) 5)
|
||||||
)
|
)
|
@ -1,3 +1,4 @@
|
|||||||
(
|
(
|
||||||
(def value 12)
|
(def value 12)
|
||||||
|
(def addOne (lambda (a) (add a 1)))
|
||||||
)
|
)
|
@ -1 +1,7 @@
|
|||||||
(run "./include.lisp")
|
(
|
||||||
|
(run "./include.lisp")
|
||||||
|
|
||||||
|
(echo value)
|
||||||
|
|
||||||
|
(echo (addOne value))
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user