lish/examples/higher-order.lsh
Yann Esposito (Yogsototh) 87c9b2e553
added comment support
2017-04-17 17:35:28 +02:00

12 lines
No EOL
406 B
Text

def inc (fn [x] (+ x 1))
def map (fn [f lst]
(if (empty? lst)
[]
(cons (f (first lst))
(map f (rest lst)))))
def test (fn [name expr]
(if expr
(prn (str name " OK"))
(prn (str name " FAILED"))))
test "map" (= [2 3 4] (map inc [1 2 3]))
test "double map" (= [3 4 5] (map inc (map inc [1 2 3])))