Re: I couldn't understand why PHP is so popular. The PHP code looks so horrible compared with Java.
- From: Michael Fesser <netizen@xxxxxx>
- Date: Tue, 29 Apr 2008 16:03:54 +0200
..oO(Rik Wasmus)
Well, offcourse it's deliberately obscure.
It creates triangles based on a number:
$test.pl 1
/\
/\/\
$test.pl 2
/\
/\/\
/\ /\
/\/\/\/\
$test.pl 3
/\
/\/\
/\ /\
/\/\/\/\
/\ /\
/\/\ /\/\
/\ /\ /\ /\
/\/\/\/\/\/\/\/\
[...]
JFTR: These structures are called Sierpinski triangles and are quite
well-known fractals.
http://en.wikipedia.org/wiki/Sierpinski_triangle
Here's something similar in PHP, also quite famous:
<pre><?php $c=0;for($y=1.2;$y>-1.3;$y-=0.1){for($x=-2.08;$x<.92;$x+=.04){$r=
$n=0;for($h=127;$r*$r+$n*$n<4&&--$h>32;){$d=$r;$r=$r*$r-$n*$n+$x;$n=2*$d*$n+
$y;}($x>0.98)?print chr(10):print chr($h);if(++$c%75==0)print"\n";}}?></pre>
Micha
.
- References:
- I couldn't understand why PHP is so popular. The PHP code looks so horrible compared with Java.
- From: tenxian
- Re: I couldn't understand why PHP is so popular. The PHP code looks so horrible compared with Java.
- From: Rik Wasmus
- Re: I couldn't understand why PHP is so popular. The PHP code looks so horrible compared with Java.
- From: Erwin Moller
- Re: I couldn't understand why PHP is so popular. The PHP code looks so horrible compared with Java.
- From: Tim Streater
- Re: I couldn't understand why PHP is so popular. The PHP code looks so horrible compared with Java.
- From: Rik Wasmus
- I couldn't understand why PHP is so popular. The PHP code looks so horrible compared with Java.
- Prev by Date: Re: I couldn't understand why PHP is so popular. The PHP code looks so horrible compared with Java.
- Next by Date: [OT] Re: getting absolute directory path?
- Previous by thread: Re: I couldn't understand why PHP is so popular. The PHP code looks so horrible compared with Java.
- Next by thread: Re: I couldn't understand why PHP is so popular. The PHP code looks so horrible compared with Java.
- Index(es):