view samples/hashset.tp @ 212:32080f96c3a0

Implement matchOne matching macro. Support more AST node types in zeroPlus matching macro.
author Mike Pavone <pavone@retrodev.com>
date Sat, 30 Nov 2013 15:05:24 -0800
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"
			}
		}
	}
}