News for hackers. Stuff that matters.
Re:Conway's Game of Life in CoffeeScript by d0m on Monday May 16, 2011 @11:59PM (#2555203)
Pretty clean code! A small suggestion:

  cell.live = false if count < 2 or count > 3
  cell.live = true  if count == 3
Could become:

  cell.live = count < 2 or count > 3
  cell.live = count == 3
since it's a bit redundant to write "true" since it's already a boolean expression. It's a little bit like saying:

  if a == true:
    return true
  else:
    return false
instead of:

  return a // Agreed that a could be a "truth" value without being the real "true". Still:

  return !!a // With a hack
Re:Conway's Game of Life in CoffeeScript by ggchappell on Tuesday May 17, 2011 @12:30AM (#2555284)
Nope. The point of those if's is that the value of cell.live remains unchanged if the condition is false. Your code does not do that.

What should happen is that, if count is 3, then cell.live becomes true. If count is 2, then cell.live retains its previous value. For all other values of count, cell.live becomes false.

Re:Conway's Game of Life in CoffeeScript by jashkenas on Tuesday May 17, 2011 @12:07AM (#2555219)
Or simply:

    cell.live = count is 3
no?
Re:Conway's Game of Life in CoffeeScript by ggchappell on Tuesday May 17, 2011 @12:26AM (#2555277)
No. You aren't handling the case when count is 2 correctly. In that case, cell.live should remain unchanged, while you are setting it to false. (Note, however, that the code in the comment you are replying to is also incorrect. And does the same thing as your code. So you posted a correct transformation of incorrect code, that keeps it incorrect.)
Re:Conway's Game of Life in CoffeeScript by abarrett on Tuesday May 17, 2011 @07:10AM (#2555999)
The original version still contains redundancy. It would be:

    cell.live = count == 3 if count != 2
Re:Conway's Game of Life in CoffeeScript by ggchappell on Tuesday May 17, 2011 @10:28AM (#2556452)
Yes, that would do it.