[squeak-dev] AMB

Stéphane Rollandin lecteur at zogotounga.net
Mon Jun 30 16:36:52 UTC 2008

from the class comment of AMB, in the attached sar
(coming soon to a SqueakMap near you):

this is the "ambigous", "nondeterminist", "angelic" operator aka amb

... more seriously described as a declarative control flow statement 
able to enumerate over finite domains all values that make a program 
terminate. it uses continuations to walk the tree of possible tuples, 
backtracking when the program fails.

the amazing thing is the simplicity of the code: four short or very 
short methods on the instance side, the class side methods only 
providing syntactic sugar.

and it can do incredible things such as:

AMB assert: [:string :n :char | (string occurrencesOf: char) = n]
	over: #('maman' 'barbapapa' 'guiliguili' 'arthur' 'chtulu')
	and: #(2 4 1)
	and: #($m $b $a $i $u)

see AMBTest for more magic.

I would have been unable to implement this by myself ! this is a port of 
the code by Dorai Sitaram which is the reference documentation for amb:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: AMB.sar
Type: application/octet-stream
Size: 3202 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080630/5237cecc/AMB.obj

More information about the Squeak-dev mailing list