あれ、思ったより綺麗に書けたぞ。 # Amb evaluator # See http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-28.html#%_sec_4.3 # Global variable for amb evaluator amb_variable_name = [] amb_possible = [] def comb(lol): """ make all combination from a list of lists """ if not lol: yield [] else: for x in lol[0]: for y in comb(lol[1:]): yield [x] + y def amb(v, l): """ set global variable for amb evaluator """ amb_v
![Python でSICP4.3 Nondeterministic Computing - なつたん](https://cdn-ak-scissors.b.st-hatena.com/image/square/de62e9244ef99b3227ad9307b09249537676dfbe/height=288;version=1;width=512/http%3A%2F%2Fnatu.txt-nifty.com%2F.shared-cocolog%2Fnifty_managed%2Fimages%2Fweb%2Fogp%2Fdefault.png)