[plt-scheme] Re: problem with backtracking order of nested ambs
Hi Chongkai,
this would be great if it worked also in case the first amb fails...
but it seems it doesn't:
(let ((x (amb 3 5 7)))
(assert (even? x))
(amb x 77))
Amb tree exhausted
It seems it justs hangs after the first amb and never tries the second
- which is exactly what I have to avoid...
On 5 Okt., 23:03, Chongkai Zhu <c... at cs.utah.edu> wrote:
> Maybe you want something like:
>
> (let ((x (amb 3 5 4)))
> (assert (even? x))
> (amb x 77))
>
> Chongkai
>
>
>
> keyd... at gmx.de wrote:
> > Hi all,
>
> > I have a problem with the backtracking order of nested ambs which
> > makes that I cannot get the result I need. I've made up a dummy example:
>
> > (let ((x (amb 3 5 4)))
> > (let ((result (amb (begin (assert (even? x)) x) 77)))
> > result))
>
> > I would need amb to first try all of '(3 5 4) and only after that,
> > take 77 as last possible way out.
>
> > In practice, I want to generate a list with amb, then check if every
> > item is unique, if not, try all other possible ways to compose the
> > list - and only there's no way to get it unique,
> > decide that "ok, nearly unique is fine too", such that 2 elements may
> > be the same, so try and assert that... and so on, until I can be sure
> > that at least the program will not fail,
> > not producing any results at all.
>
> > I'd be glad for any hints what I'm doing wrong here...
>
> > Thanks a lot in advance,
> > Sigrid
>
> > _________________________________________________
> > For list-related administrative tasks:
> > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme