[plt-scheme] problem with amb macros

From: Sigrid Keydana (keydana at gmx.de)
Date: Sun Dec 14 12:47:12 EST 2008


please excuse my question as it's not about PLT-scheme specific  - I'm a
complete autodidact studying on my own, trying to solve the SICP
exercises, and I think this group is very helpful and instructive :-)

I want to solve the amb exercises in SICP not always using the custom
amb evaluator from the book, but one of the existing macros (as an
exercise to employ these macros "in the real world").
However, with both the amb macro from the Dorai Sitaram book and one
taken from http://community.schemewiki.org/?amb, I do not get the
expected behavior when I call (amb) again to get the residual alternatives.
E.g. in exercise 4.45, there should be 5 alternatives, but I get "amb
tree exhausted" already when I call (amb) after the first try.

In general it seems the failure continuations are stored correctly in
the macros - simple cases like

1) (amb 1 2) -> 1
2) (amb) -> 2

work as expected, but for the more complicated cases as the
language-parsing or the puzzles (e.g., exercise 4.43 in the
"more-than-one-solution" version) it seems that the macros are not
really equivalent of the SICP amb evaluator... Is this possible?

Many thanks in advance for any help

Posted on the users mailing list.