I don't know, but here's some output of the (first) Haskell example with
modified input data, producing two possibilities (ececuted from within
GHCi):

amb = id

example = do
  w1 <-  amb ["the", "that", "a"]
  w2 <-  amb ["frog", "elephant", "thing"]
  w3 <-  amb ["walked", "treaded", "grows"]
  w4 <-  amb ["slowly", "quickly","dumbly"]
  unless (joins w1 w2) (amb [])
  unless (joins w2 w3) (amb [])
  unless (joins w3 w4) (amb [])
  unwords [w1, w2, w3, w4]


*Main> example
"the elephant treaded dumblythat thing grows slowly"


It's the same result (except format) as from the list comprehension :

allcombs = [ [a,b,c,d] | a <- z1, b <- z2, c <- z3, d <- z4, joins a b,
joins b c, joins c d ]

*Main> allcombs
[["the","elephant","treaded","dumbly"],["that","thing","grows","slowly"]]


=@@i


Hamish Harvey schreef:
> Arie,
>
> On Tue, Nov 25, 2008 at 14:40, Arie Groeneveld <[EMAIL PROTECTED]> wrote:
>   
>> After reading some literature about subject I can only conclude
>> solutions like the Haskell example are not really what Amb should do. It
>> just produces all possibilities at once.
>>     
>
> I don't think it does. Haskell is lazily evaluated. Only as much of
> the list is calculated as needed. When you ask Haskell to print the
> list, it prints it all, finding each member in turn, but it is only
> computing those members because it needs to to print them. Until that
> time the list exists more as a specification than as data.
>
> Cheers,
> Hamish
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
>   
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to