3 ms·
McCarthy's Ambiguous Operator (2005)
- deleted 3y ago[deleted]
- dang 3y agoRelated. Others? McCarthy's Ambiguous Operator - https://news.ycombinator.com/item?id=32809727 https://news.ycombinator.com/item?id=32809727 - Sept 2022 (1 comment) Show HN: Implementation of John McCarthy's AMB operator in Portable Common Lisp - https://news.ycombinator.com/item?id=29912930 https://news.ycombinator.com/item?id=29912930 - Jan 2022 (2 comments) McCarthy's Ambiguous Operator (2005) - https://news.ycombinator.com/item?id=19141197 https://news.ycombinator.com/item?id=19141197 - Feb 2019 (42 comments) McCarthy's amb operator in Python - https://news.ycombinator.com/item?id=2941947 https://news.ycombinator.com/item?id=2941947 - Aug 2011 (2 comments)
- nxobject 3y agoIf you're interested, SICP also has a chapter on the amb operator – although it has you construct your own evaluator. [1] [1] https://sarabander.github.io/sicp/html/4_002e3.xhtml https://sarabander.github.io/sicp/html/4_002e3.xhtml
- Zambyte 3y agoThis page also has a relatively simple implementation of amb in Scheme[0], though it assumes case insensitivity which is no longer default by the standard. [0] http://community.schemewiki.org/?amb http://community.schemewiki.org/?amb
- sterlind 3y agoisn't this basic Prolog? ?- member(X,[1,2,3]),member(Y,[4,5,6]),X*Y#=8.
- dragonwriter 3y agoYes, but: FTFA: “Back in 1961, John McCarthy (the inventor of LISP) described an interesting mathematical operator called amb.” Prolog: “First appeared 1972” [0] [0] https://en.wikipedia.org/wiki/Prolog https://en.wikipedia.org/wiki/Prolog
- throwanem 3y agoNo. The example describes it in terms of satisfying a predicate, but only by chance; this article actually demonstrates continuations, a language feature more commonly seen in Scheme and much more clearly described at https://courses.cs.washington.edu/courses/cse341/04wi/lectures/15-scheme-continuations.html https://courses.cs.washington.edu/courses/cse341/04wi/lectur...
- dragonwriter 3y agoIncidentally, the sample code, in modern Ruby will (at a minimum) require: require "continuation" at the top of the file, because callcc has been moved out of the core language into stdlib quite a while ago (I think with Ruby 1.9.)
- mjb 3y agoLook, a model checker! More seriously, it's interesting how this kind of thing is trivial to express in some languages (TLA+, prolog, Alloy), ok in some (Ruby, scheme), and super hard in others. The ruby model and specification would translate almost line-by-line into TLA+, and TLC could do what the backtracking implementation does.
- lostmsu 3y agoUnfortunately, I can't read Ruby. Are there examples of implementations for amb in other languages? C#/Rust/Python?