Talk:Amb: Difference between revisions

→‎Go: Updated link to McCarthy paper.
(→‎Go: new section)
(→‎Go: Updated link to McCarthy paper.)
Line 65:
== Go ==
 
I added a solution inspired more by [http://www-formal.stanford.edu/jmc/basis.html| McCarthy's original paper] than the SICP presentation. McCarthy talks about functions which may be "undefined" in some cases and says, "...when the computation process fails to terminate, the result is undefined." (bottom of p. 7 in the PDF.) The Go version handles this with channels and goroutinesgo routines.
 
: It seems they've taken down that server. Here's the Wayback Machine link: [https://web.archive.org/web/20120901194931/http://www-formal.stanford.edu/jmc/basis.html McCarthy's Paper via Wayback Machine] --[[User:Rabuf|Rabuf]] ([[User talk:Rabuf|talk]]) 17:09, 7 November 2013 (UTC)
 
He defines amb as a binary operator on x and y where either or both may be undefined. That is, x and y are separate computations which may or may not terminate. He talks of functions having possible values (plural) and while he doesn't specify that amb must enumerate its defined values, we assume so because we want to do backtracking. This binary enumerating amb can be composed into a form that works with multiple values. The result, in a context of computations that take an unknown amount of time, is a form that may yield a number of values, but perhaps not immediately, perhaps not all at once, perhaps never. A goroutine supplying values over a channel has this capability.
Anonymous user