Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/accumulate.janet
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(reduce + 0 [1 2 3 4]) # -> 10
(accumulate + 0 [1 2 3 4]) # -> @[1 3 6 10]

(reduce + 0 []) # -> 0
(accumulate + 0 []) # -> @[]

(reduce string "" ["J" "a" "n" "e" "t"]) # -> "Janet"
(accumulate string "" ["J" "a" "n" "e" "t"]) # -> @["J" "Ja" "Jan" "Jane" "Janet"]
8 changes: 8 additions & 0 deletions examples/accumulate2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(reduce2 + [1 2 3 4]) # -> 10
(accumulate2 + [1 2 3 4]) # -> @[1 3 6 10]

(reduce2 + []) # -> nil
(accumulate2 + []) # -> @[]

(reduce2 max [1 4 2 3 9 5]) # -> 9
(accumulate2 max [1 4 2 3 9 5]) # -> @[1 4 4 4 9 9]