[plt-scheme] problem with backtracking order of nested ambs

From: keydana at gmx.de (keydana at gmx.de)
Date: Mon Oct 5 15:58:47 EDT 2009

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)))

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,

Posted on the users mailing list.