News for hackers. Stuff that matters.
Re:Who owns the fish? A Common Lisp solution to "Einstein's... by Crito on Monday May 12, 2014 @05:55PM (#7735638)
Hmm, seems like this could potentially be solved in a cool way using the amb operator. Might have to give that a shot later today.
Re:Who owns the fish? A Common Lisp solution to "Einstein's... by japr59 on Monday May 12, 2014 @07:15PM (#7735942)
Definitely. For anybody interested, http://mitpress.mit.edu/sicp/full-text/sicp/book/node90.html offers a nice introduction to the amb operator.

One issue that I found when solving problems like this is that, to achieve speed, it can become necessary to use many nested lets. That could hurt readability. Nobody wants to see a line of code nested 20 tabs deep!

Re:Who owns the fish? A Common Lisp solution to "Einstein's... by tonetheman on Monday May 12, 2014 @08:10PM (#7736049)
Oh node programmers love that... :)
Re:Who owns the fish? A Common Lisp solution to "Einstein's... by twfarland on Monday May 12, 2014 @08:58PM (#7736162)
Haskell lists also work nicely for nondeterministic computation.
Re:Who owns the fish? A Common Lisp solution to "Einstein's... by andolanra on Monday May 12, 2014 @10:22PM (#7736332)
Indeed, we can use Haskell lists as the amb operator and implement require as

    require :: Bool -> [()]
    require True  = return ()
    require False = []
and then express amb-like computations in effectively the same way:

    sample :: [(Int, Int)]
    sample = do
      x <- [1,2,3,4,5]
      y <- [1,2,3,4,5]
      require (x == 2 * y)
      return (x, y)
after which the value of sample is [(2,1),(4,2)]. (Also, my require is effectively the same as the guard function found in Control.Monad, specialized for lists.)