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