Conway's Game of Life in CoffeeScript
willbailey.name
Conway's Game of Life in CoffeeScript
1–10 of 23 posts
Re: Conway's Game of Life in CoffeeScript
#2Re: Conway's Game of Life in CoffeeScript
#3Re: Conway's Game of Life in CoffeeScript
#4I've been playing around with CoffeeScript and docco a bit lately and I thought I'd share this little project. Thanks to Jeremy Ashkenas for creating these fantastic tools.
Docco always impresses too, eh?
I really like the use of:
this[key] = value for key, value of options
I'm going to use that for sure :)
Re: Conway's Game of Life in CoffeeScript
#5Be sure to check out the annotated source - http://willbailey.name/conway/docs/conway.html
Re: Conway's Game of Life in CoffeeScript
#6 cell.live = false if count 3
cell.live = true if count == 3
Could become: cell.live = 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 hackRe: Conway's Game of Life in CoffeeScript
#7Pretty clean code! A small suggestion: cell.live = false if count 3 cell.live = true if count == 3 Could become: cell.live = 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: ret…
cell.live = count is 3
no?Re: Conway's Game of Life in CoffeeScript
#8Be sure to check out the annotated source - http://willbailey.name/conway/docs/conway.html
I really like how that is done. It would be great to be able to annotate source code like this within your IDE.
Re: Conway's Game of Life in CoffeeScript
#9Re: Conway's Game of Life in CoffeeScript
#10Pretty clean code! A small suggestion: cell.live = false if count 3 cell.live = true if count == 3 Could become: cell.live = 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: ret…
Or simply: cell.live = count is 3 no?