# HG changeset patch # User Michael Pavone # Date 1406351867 25200 # Node ID 5a27dd6f03cd005c12d5e5eff025da81193cddff # Parent 5a36fda13a4713e612f0343968bd0bee1ea98f77 Added filter function diff -r 5a36fda13a47 -r 5a27dd6f03cd code/mike00.lm --- a/code/mike00.lm Fri Jul 25 22:13:17 2014 -0700 +++ b/code/mike00.lm Fri Jul 25 22:17:47 2014 -0700 @@ -45,6 +45,17 @@ acc } + filter <- :lst pred { + new <- [] + while: { not: (lst isInteger?) } do: { + if: (pred: (lst value)) { + new <- (lst value) | new + } else: {} + lst <- lst tail + } + reverse: new + } + makeTree:size <- :lst :size { ret <- 0 sub <- 0 @@ -174,6 +185,7 @@ print: (tree: tree set: 6 to: 42) print: (tree: tree set: 8 to: 42) print: (fold: lst 0 with: :acc el { acc + el }) + print: (filter: lst :el { el > 4 }) } } \ No newline at end of file