chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Using the amb egg


From: Thomas Chust
Subject: Re: [Chicken-users] Using the amb egg
Date: Tue, 10 Aug 2010 14:40:15 +0200

2010/8/10 Jeronimo Pellegrini <address@hidden>:
> [...]
> 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).
> [...]

Hello Jeronimo,

using amb at the top level without an enclosing context providing form
is possible, but it can be confusing. In your example you actually see
two return values from the amb forms in the first let construct and
none from those in the second let construct!

Unless you know exactly what you are doing, I would recommend to
enclose all applications of amb in amb-find or amb-collect forms. Your
example could be modified like this:

  $ csi

  CHICKEN
  (c)2008-2010 The Chicken Team
  (c)2000-2007 Felix L. Winkelmann
  Version 4.5.6
  linux-unix-gnu-x86 [ manyargs dload ptables ]
  compiled 2010-08-08 on kali (Linux)

  [...]
  #;1> (use amb)
  [...]
  #;2> (amb-collect
  --->   (let ((a (amb 1 2 3)) (b (amb -1 -2 -3)))
  --->     (amb-assert (= (+ a b) 0))
  --->     (list a b)))
  ((1 -1) (2 -2) (3 -3))
  #;3> (amb-collect
  --->   (let ((a (amb 1 2 3)) (b (amb -1 -2 -3)))
  --->     (amb-assert (= (+ a b) 10))
  --->     (list a b)))
  ()

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]