fix fold/empty list bug

This commit is contained in:
Scott Richmond 2024-06-20 16:36:01 -04:00
parent 694b8adc60
commit bf7dfe94bd
2 changed files with 4 additions and 1 deletions

View File

@ -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 (

View File

@ -52,7 +52,8 @@
(comment
# (do
(def source `
rest ([])
fn id (x) -> x
map (id, [])
`)
(def out (-> source
ludus