Mercurial > repos > icfp2014
comparison code/mike00.lm @ 27:abd8ceef0dd8
Added flatten function
author | William Morgan <billjunk@mrgn.org> |
---|---|
date | Fri, 25 Jul 2014 23:36:17 -0700 |
parents | edc89d9c9e10 |
children |
comparison
equal
deleted
inserted
replaced
26:4f7a421e77c6 | 27:abd8ceef0dd8 |
---|---|
52 new <- (lst value) | new | 52 new <- (lst value) | new |
53 } else: {} | 53 } else: {} |
54 lst <- lst tail | 54 lst <- lst tail |
55 } | 55 } |
56 reverse: new | 56 reverse: new |
57 } | |
58 | |
59 flatten <- :lst { | |
60 fold: lst [] with: :acc el { | |
61 fold: el acc with: :iacc iel { | |
62 iel | iacc | |
63 } | |
64 } | |
57 } | 65 } |
58 | 66 |
59 makeTree:size <- :lst :size { | 67 makeTree:size <- :lst :size { |
60 ret <- 0 | 68 ret <- 0 |
61 sub <- 0 | 69 sub <- 0 |
189 print: (tree: tree set: 6 to: 42) | 197 print: (tree: tree set: 6 to: 42) |
190 print: (tree: tree set: 8 to: 42) | 198 print: (tree: tree set: 8 to: 42) |
191 print: (fold: lst 0 with: :acc el { acc + el }) | 199 print: (fold: lst 0 with: :acc el { acc + el }) |
192 print: (filter: lst :el { el > 4 }) | 200 print: (filter: lst :el { el > 4 }) |
193 print: (tree: tree update: 8 with: :el { el + 29 }) | 201 print: (tree: tree update: 8 with: :el { el + 29 }) |
202 print: (flatten: [lst lst lst]) | |
194 } | 203 } |
195 | 204 |
196 } | 205 } |