Mercurial > repos > icfp2014
diff code/mike00.lm @ 21:5a27dd6f03cd
Added filter function
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 25 Jul 2014 22:17:47 -0700 |
parents | 5a36fda13a47 |
children | edc89d9c9e10 |
line wrap: on
line diff
--- 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