add def implementation for lambdas

This commit is contained in:
Quentin Leonetti 2019-07-14 06:07:05 +02:00
parent 950716f2f3
commit 15f1e6a2b1
4 changed files with 12 additions and 3 deletions

View File

@ -35,7 +35,7 @@ function Lisp (input, lib) {
return interpret(input[2], letContext)
},
def: function (input, context) {
context.scope[input[1].value] = input[2].value
context.scope[input[1].value] = interpret(input[2], context)
return input[2]
},
lambda: function (input, context) {

View File

@ -41,5 +41,7 @@
; Scope
(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)
)

View File

@ -1,3 +1,4 @@
(
(def value 12)
(def addOne (lambda (a) (add a 1)))
)

View File

@ -1 +1,7 @@
(run "./include.lisp")
(
(run "./include.lisp")
(echo value)
(echo (addOne value))
)