Talk:Amb: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 17: Line 17:


Wouldn't it more sense just to call the task something like "nondeterministic choice" and leave it to the implementations to use whatever language feature works best for that? The SICP implenetation uses call/cc and side-effects, but to require a special operator ''amb'' for Prolog, where nondeterminism is in-built, is a bit silly. Python has generators. And it's equally silly in the Haskell example, where ''amb'' just reduces to the identity in the List-Monad. One could emulate the construction in the Continuation-and-State-Monad, but that would be even more silly :-) After all, the article "Replacing failure with a list of successes" was written long after SICP. The List-Monad construction also probably carries over more easily to other languages than call/cc. --[[User:Dirkt|Dirkt]] 02:22, 25 March 2008 (MDT)
Wouldn't it more sense just to call the task something like "nondeterministic choice" and leave it to the implementations to use whatever language feature works best for that? The SICP implenetation uses call/cc and side-effects, but to require a special operator ''amb'' for Prolog, where nondeterminism is in-built, is a bit silly. Python has generators. And it's equally silly in the Haskell example, where ''amb'' just reduces to the identity in the List-Monad. One could emulate the construction in the Continuation-and-State-Monad, but that would be even more silly :-) After all, the article "Replacing failure with a list of successes" was written long after SICP. The List-Monad construction also probably carries over more easily to other languages than call/cc. --[[User:Dirkt|Dirkt]] 02:22, 25 March 2008 (MDT)

== Haskell ==

The code

unless (joins w1 w2) (amb [])

could be replaced with simply

guard (joins w1 w2)

I didn't make the change because I don't know if you are trying to point out how to use (amb []).