Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
19
Task/Catamorphism/EchoLisp/catamorphism.echolisp
Normal file
19
Task/Catamorphism/EchoLisp/catamorphism.echolisp
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
;; rem : the foldX family always need an initial value
|
||||
;; fold left a list
|
||||
(foldl + 0 (iota 10)) ;; 0 + 1 + .. + 9
|
||||
→ 45
|
||||
|
||||
;; fold left a sequence
|
||||
(lib 'sequences)
|
||||
(foldl * 1 [ 1 .. 10])
|
||||
→ 362880 ;; 10!
|
||||
|
||||
;; folding left and right
|
||||
(foldl / 1 ' ( 1 2 3 4))
|
||||
→ 8/3
|
||||
(foldr / 1 '(1 2 3 4))
|
||||
→ 3/8
|
||||
|
||||
;;scanl gives the list (or sequence) of intermediate values :
|
||||
(scanl * 1 '( 1 2 3 4 5))
|
||||
→ (1 1 2 6 24 120)
|
||||
Loading…
Add table
Add a link
Reference in a new issue