fix fold
/empty list bug
This commit is contained in:
parent
694b8adc60
commit
bf7dfe94bd
|
@ -192,7 +192,9 @@ fn list {
|
|||
|
||||
fn fold {
|
||||
"Folds a list."
|
||||
(f as :fn, []) -> []
|
||||
(f as :fn, xs as :list) -> fold (f, xs, f ())
|
||||
(f as :fn, [], root) -> []
|
||||
(f as :fn, xs as :list, root) -> loop (root, first (xs), rest (xs)) with {
|
||||
(prev, curr, []) -> f (prev, curr)
|
||||
(prev, curr, remaining) -> recur (
|
||||
|
|
|
@ -52,7 +52,8 @@
|
|||
(comment
|
||||
# (do
|
||||
(def source `
|
||||
rest ([])
|
||||
fn id (x) -> x
|
||||
map (id, [])
|
||||
`)
|
||||
(def out (-> source
|
||||
ludus
|
||||
|
|
Loading…
Reference in New Issue
Block a user