Mercurial > repos > tabletprog
view samples/hashset.tp @ 256:03a07e540b9f
Memoize results of match:where:yield and matchOne: macros. Fix opsym rule to use the symbol ast node.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 01 Jun 2014 00:14:36 -0700 |
parents | cbc92ee13f35 |
children |
line wrap: on
line source
#{ 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" } } } }