PREVIOUS  TABLE OF CONTENTS 

The Perl Journal One-Liners

TPJ One-Liner #11

The Game Of Life

TPJ One-Liner #11

use PDL; use PDL::Image2D;
use PDL::Graphics::TriD;nokeeptwiddling3d;
$d=byte(random(zeroes(40,40))>0.85);
$k=byte [[1,1,1],[1,0,1],[1,1,1]];
do{ imagrgb [$d]; $s=conv2d($d,$k);
$d&=($s>4);$d&=($s>1);$d|=($s==3);}
while (!twiddle3d);

Courtesy of Robin Williams.

TPJ One-Liner #12

DeMorgan's Rule:

if (!$a || $b != $c) { ... }

is equivalent to

unless ( $a && $b == $c ) { ... }


PREVIOUS  TABLE OF CONTENTS