Added support for λ

This commit is contained in:
Devine Lu Linvega
2019-07-21 09:52:37 +09:00
parent 3ea7fff85f
commit 938a9d22ec
6 changed files with 25 additions and 24 deletions

View File

@@ -8,9 +8,6 @@
(defn add-two (a) (add 2 a))
(echo (add-two 4))
; run
; use a lambda
(times 5
(lambda
(a)
(echo
(concat "time:" a))))
(λ (a) (echo (concat "time:" a))))

View File

@@ -35,14 +35,14 @@
(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 negative step" (range 0 -4 -1) (0 -1 -2 -3 -4))
(test "map" (map (lambda (a) (add 1 a)) (1 2 3)) (2 3 4))
(test "filter" (filter (lambda (a) (eq 0 (mod a 2))) (2 3 4 5 6)) (2 4 6))
(test "reduce" (reduce (lambda (acc val) (add acc val)) (1 2 3) 4) 10)
(test "map" (map (λ (a) (add 1 a)) (1 2 3)) (2 3 4))
(test "filter" (filter (λ (a) (eq 0 (mod a 2))) (2 3 4 5 6)) (2 4 6))
(test "reduce" (reduce (λ (acc val) (add acc val)) (1 2 3) 4) 10)
; Scope
(def aaa 123)
(def addOne (lambda (a) (add a 1)))
(def addOne (λ (a) (add a 1)))
(test "def - value" aaa 123)
(test "def - func" (addOne 4) 5)
(defn addTwo (a) (add 2 a))

View File

@@ -16,7 +16,7 @@
(defn dejong (r a b c d)
(reduce
(lambda (acc val)
(λ (acc val)
(first (
(_dejong (first acc) (last acc) a b c d)
)))

View File

@@ -2,7 +2,7 @@
(clear)
(def col
(lambda
(λ
(i)
(of
(
@@ -16,7 +16,7 @@
(theme "b_inv"))
(mod i 8))))
(def rec
(lambda
(λ
(v i)
(if
(gt v 0)