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

View File

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