Mercurial > repos > tabletprog
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/hashset.tp Mon Jul 16 01:22:48 2012 -0700 @@ -0,0 +1,24 @@ +#{ + main <- { + inset <- #["foo" "bar" "foobar" 1 2 3] + notin <- #["baz" "qux" "bazqux" 4 5 6] + myset <- sets hash + foreach: inset :idx el { + myset add: el + } + foreach: inset :idx el { + if: (myset contains?: el) { + print: "set contains " . el . "\n" + } else: { + print: "set doesn't contain " . el . "\n" + } + } + foreach: notin :idx el { + if: (myset contains?: el) { + print: "set contains " . el . "\n" + } else: { + print: "set doesn't contain " . el . "\n" + } + } + } +}