The amb procedure works wonders. It does -seem- to have a serious issue, if formed as offered in "Teach Yourself Scheme in Fixnum Days" and other places.
That problem is arbitraririly (lazy) recursively defining amb functions. It just seems to refuse to work...Either from the recursion, or from the promises, which brings us to Context Free Grammars.
It's very easy to define a CFG's branches as an AMB of promises
Here's an example of what I mean. ("force-tree" just runs through every branch of a list and forces any promises it finds, until no promises exist in that tree)
;Define a
> (define (cfgA) (amb (list "") (list "a" (delay (cfgA)) "b") ))
> (define foo (cfgA))
("")
> foo
("")
> (amb)
("a" ("") "b")
> foo
("a" ("") "b")
> (amb) ;;Weird output here..it doesn't change one bit!
("a" ("") "b")
> foo
("a" ("") "b")
> (amb) ;;Strange here, too! Why exhaust the tree when we have options?
. Amb tree exhausted
It seems to me amb doesn't work well with promises... If that were to resolve, a million new things would be work-trivial (while probably not overly efficient) in Scheme.