1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-11 13:55:55 +03:00

core.mal: test each non trivial recursion

This commit is contained in:
Nicolas Boulenguez 2019-05-11 12:37:03 +02:00
parent 75dd96947f
commit e044a11ab1

View File

@ -153,6 +153,46 @@ x
;; Loading core.mal
(load-file "../core.mal")
;; Testing reduce
(reduce + 7 [])
;=>7
(reduce + 7 [1])
;=>8
(reduce + 7 [1 2])
;=>10
(reduce * 7 [-1 2])
;=>-14
(reduce concat [1] [[2] [3]])
;=>(1 2 3)
(reduce str "a" ["b" "c"])
;=>"abc"
;; Testing every?
(every? first [])
;=>true
(every? first [[1] [2]])
;=>true
(every? first [[1] [nil] []])
;=>false
;; Testing some
(some first [])
;=>nil
(some first [[nil] [1] []])
;=>1
;; Testing and macro
(and)
;=>true
(and 1)
;=>1
(and 1 2 3 4)
;=>4
(and false 2)
;=>false
(and true 1 nil false)
;=>nil
;; Testing -> macro
(-> 7)
;=>7