[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Using the amb egg
From: |
Ivan Shmakov |
Subject: |
Re: [Chicken-users] Using the amb egg |
Date: |
Tue, 10 Aug 2010 13:57:11 +0700 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
>>>>> Jeronimo Pellegrini <address@hidden> writes:
> Hi,
> I've installed the amb egg and could use it, but I'm a bit confused:
> #;1> (use amb amb-extras)
> ...
> #;2> (let ((a (amb 1 2 3)) (b (amb -1 -2 -3))) (required (= (+ a b) 0))
> (list a b))
> (1 -1)
> #;3> (let ((a (amb 1 2 3)) (b (amb -1 -2 -3))) (required (= (+ a b) 10))
> (list a b))
> (2 -2)
> So, out of the scope of the first LET I use amb and require again,
> and it returned values that would work for the first time (but not
> the second).
But note that the latter is the result of the first ‘let’, and
not the second.
[…]
> What's the semantics of amb and require in this situation?
That's quite simple — ‘amb’ returns a value that won't be
followed by a contradiction. The first expression was followed
by the second, which, in turn, has led to a contradiction.
Therefore, first ‘amb’ was evaluated for one more time, giving
the latter result.
> Am I supposed to do something between the two lets? (Does amb need a
> "restart" or something?)
[…]
--
FSF associate member #7257
pgpJYy6q2HOrk.pgp
Description: PGP signature