This commit is contained in:
Quentin Leonetti 2019-07-14 05:56:02 +02:00
parent 88bf708ed2
commit 530bd1a2d9
4 changed files with 14 additions and 1 deletions

View File

@ -34,6 +34,10 @@ function Lisp (input, lib) {
return interpret(input[2], letContext) return interpret(input[2], letContext)
}, },
def: function (input, context) {
context.scope[input[1].value] = input[2].value
return input[2]
},
lambda: function (input, context) { lambda: function (input, context) {
return function () { return function () {
const lambdaArguments = arguments const lambdaArguments = arguments

View File

@ -14,7 +14,7 @@
(test "clamp" (clamp 12 4 8) 8) (test "clamp" (clamp 12 4 8) 8)
(test "step" (step 12 10) 10) (test "step" (step 12 10) 10)
(test "PI" TWO_PI (mul 2 PI)) (test "PI" TWO_PI (mul 2 PI))
; Logic ; Logic
(test "lt" (lt 3 4) true) (test "lt" (lt 3 4) true)
@ -37,4 +37,9 @@
(test "range simple" (range 0 4) (0 1 2 3 4)) (test "range simple" (range 0 4) (0 1 2 3 4))
(test "range with step" (range 0 4 2) (0 2 4)) (test "range with step" (range 0 4 2) (0 2 4))
(test "range with negative step" (range 0 -4 -1) (0 -1 -2 -3 -4)) (test "range with negative step" (range 0 -4 -1) (0 -1 -2 -3 -4))
; Scope
(def aaa 123)
(test "def" aaa 123)
) )

3
examples/include.lisp Normal file
View File

@ -0,0 +1,3 @@
(
(def value 12)
)

1
examples/run.lisp Normal file
View File

@ -0,0 +1 @@
(run "./include.lisp")