Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Prolegemona To A Future Scripting Language: Game Of Life In Perl 6by TheDamian (Vicar) |
on Apr 27, 2003 at 01:31 UTC ( [id://253438]=note: print w/replies, xml ) | Need Help?? |
That's a great effort, especially without a compiler.
Here are a few corrections and some more "idiomatic" solutions.
Comments in bold italics explain corrections on the previous line. # Indirect object syntax requires colon after invocant # Argumentless &loop is cleaner that &while for infinite loops # Bit is potentially much smaller than Int for 1/0 values # BUILD is the object initializer. # CREATE is something else entirely (see Apocalypse 12 ;-) # Setting default value to 0 reduces initialization costs # Can't declare variably dimensioned array as attribute. # Have to declare it when dimension known (i.e. in # constructor) and then bind it to attribute # Utility sub to factor out repetitive 2D iterations # Prefer &for over &loop when possible (e.g. here) # Pass &iterate a block with placeholders for $x and $y # STDIN is now $*IN Update: Fixed display method (thanks jkahn)
In Section
Cool Uses for Perl
|
|