in reply to RE (tilly) 3: The Big Test
in thread The Big Test
One I used to see regularly when in my second Basic class (*sigh*) was (in perl idiom) if ($num/2 == int($num/2)) {print "$num even!\n":}
That still gives me the willies, though it is techically correct(ish) and is more generally applicable than terminal digit inspection =) Most people these days never got taught what the mod function really does. Basic math logic skills are passed off till college.
One thing I remember from Basic was that true was -1 and false was 0, and that all logical ops returned one of those two values. We used to do this (sorta) in graphics programs to get smoothly, randomly, changing colors and positions:
my @color= (127,127,127); #256x256x256 color palette my @location= (50,50); #200x200 screen for(;;) { $color[0] += (int(rand*3)==1) - (int(rand*3)==1); $color[1] += (int(rand*2)==1) - (int(rand*4)==1); $color[2] += (int(rand*4)==1) - (int(rand*2)==1); $location[0] += (int(rand*5)) - 2; $location[1] += (int(rand*5)) - 2; @color = map {$_ % 256} @color; @location = map {$_ % 200} @location; DrawPixel(@location,@color); }
We did megacomplex things with math logic because it was blazingly fast vs. if (){}; =) Seems like a forgotten era now that I do web stuff.
--
$you = new YOU;
honk() if $you->love(perl)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: RE (tilly) 3: The Big Test
by myocom (Deacon) on Oct 18, 2000 at 05:20 UTC | |
by tilly (Archbishop) on Oct 18, 2000 at 05:29 UTC | |
by extremely (Priest) on Oct 18, 2000 at 05:34 UTC |