The experimental java implementation of Serene aka (Serene Simple)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
562 B

(def reduce
(fn (f xs initial-value)
((first xs) (reduce f (rest xs) (f initial-value (first xs))))
(true initial-value))))
(def map
(fn (f xs)
(reduce (fn (acc x) (cons acc (f x))) xs (list))))
;; Since SereneSimple only have List data structure and
;; it is effecient from the start. So the following function
;; will return (6 5 4 3 2)
(println (map (fn (x) (+ 1 x))
(list 1 2 3 4 5)))
(reduce (fn (y x)
(cons y (* x x)))
(list 1 2 3 4)