in reply to Fractal Golf anyone?

Hi Melly,

I can only see small improvements, but of course, in golf, everything counts!

Change your while loops and for loops to redo blocks and maps, for starters.  Use special variables wherever possible, like $" instead of " ", and $/ instead of "\n".  Get rid of all ; characters at the end of blocks.

Here's what I came up with so far:

$a=1;{ $b=-2; { $c='X'; $d=$b; $e=$a; map{ $g=$d; $d=$d**2-$e**2+$b; $e=2*$g*$e+$a; $c=$"if$d**2+$e**2>4 }1..50; print$c; $b+=.05; $b<1&&redo } print$/; $a-=0.1; $a>-1&&redo }

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^2: Fractal Golf anyone? (Embed assignments)
by ikegami (Patriarch) on Nov 28, 2006 at 18:03 UTC

    Another quickie tip: Embed assignments into other expressions to remove redundancy and drop line seperators.

    $b+=.05;$b<1&&redo ($b+=.05)<1&&redo $a-=0.1;$a>-1&&redo ($a-=0.1)>-1&&redo
Re^2: Fractal Golf anyone?
by Melly (Chaplain) on Nov 28, 2006 at 17:26 UTC

    Hmm, good tips (I'm new to perl-golf - this particular script was from the good old days when I played pov-golf...)

    Tom Melly, tom@tomandlu.co.uk
Re^2: Fractal Golf anyone?
by cLive ;-) (Prior) on Nov 28, 2006 at 22:58 UTC