comparison samples/hashset.tp @ 80:cbc92ee13f35

Add hash set
author Mike Pavone <pavone@retrodev.com>
date Mon, 16 Jul 2012 01:22:48 -0700
parents
children
comparison
equal deleted inserted replaced
79:7f635666c73d 80:cbc92ee13f35
1 #{
2 main <- {
3 inset <- #["foo" "bar" "foobar" 1 2 3]
4 notin <- #["baz" "qux" "bazqux" 4 5 6]
5 myset <- sets hash
6 foreach: inset :idx el {
7 myset add: el
8 }
9 foreach: inset :idx el {
10 if: (myset contains?: el) {
11 print: "set contains " . el . "\n"
12 } else: {
13 print: "set doesn't contain " . el . "\n"
14 }
15 }
16 foreach: notin :idx el {
17 if: (myset contains?: el) {
18 print: "set contains " . el . "\n"
19 } else: {
20 print: "set doesn't contain " . el . "\n"
21 }
22 }
23 }
24 }