Mercurial > repos > tabletprog
annotate src/kernel.tp @ 80:cbc92ee13f35
Add hash set
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 16 Jul 2012 01:22:48 -0700 |
parents | 96e21f525b78 |
children |
rev | line source |
---|---|
33 | 1 /* |
2 array <- #{ | |
3 new <- { | |
4 length <- 0 | |
5 #{ | |
6 each <- :fun { | |
7 repeat: length :idx { | |
8 fun: idx (get: idx) | |
9 } | |
10 } | |
11 } | |
12 } | |
13 } | |
14 */ | |
15 | |
16 true <- #{ | |
17 if:else <- :self trueblock :elseblock { | |
18 trueblock: | |
19 } | |
20 } | |
21 | |
22 false <- #{ | |
23 if:else <- :self trueblock :elseblock { | |
24 elseblock: | |
25 } | |
26 } | |
27 | |
28 filter <- :arr pred { | |
29 output <- arr slice: 0 0 | |
30 each: arr :idx el { | |
31 if: (pred: el) { | |
32 output push: el | |
33 } else: {} | |
34 } | |
35 output | |
36 } |