# HG changeset patch # User Michael Pavone # Date 1406351597 25200 # Node ID 5a36fda13a4713e612f0343968bd0bee1ea98f77 # Parent 84f595cff06280148cc32556923a7ba6abf80a58 Added fold:with function diff -r 84f595cff062 -r 5a36fda13a47 code/mike00.lm --- a/code/mike00.lm Fri Jul 25 22:09:54 2014 -0700 +++ b/code/mike00.lm Fri Jul 25 22:13:17 2014 -0700 @@ -37,6 +37,14 @@ reverse: new } + fold:with <- :lst acc :fun { + while: { not: (lst isInteger?) } do: { + acc <- fun: acc (lst value) + lst <- lst tail + } + acc + } + makeTree:size <- :lst :size { ret <- 0 sub <- 0 @@ -165,6 +173,7 @@ print: (tree: tree set: 0 to: 42) print: (tree: tree set: 6 to: 42) print: (tree: tree set: 8 to: 42) + print: (fold: lst 0 with: :acc el { acc + el }) } } \ No newline at end of file