in reply to Fractal Golf anyone?

138 (Melly: 165, liverpole: 156)

map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;$c=X;map{($d,$e)=(2*$d*$e+$a,$ e**2-$d**2+$b);$c=$"if$d**2+$e**2>4}1..50;print$c}0..59;print$/}0..20

Notes:

Spaced out:

map { $a = 1-$_/10; map{ $d = $a; $e = $b = $_/20-2; $c = X; map { ($d, $e) = (2*$d*$e+$a, $e**2-$d**2+$b); $c = $" if $d**2+$e**2 > 4 } 1..50; print $c } 0..59; print $/ } 0..20

Replies are listed 'Best First'.
Re^2: Fractal Golf anyone?
by Melly (Chaplain) on Nov 29, 2006 at 10:40 UTC

    Mmm, nice - I thought at first the list assignment for $d and $e was a false economy, but on closer inspection, it somehow avoids the need for a temporary value for $d - care to explain to an idiot? (I assume that the new value for $d is not used in the evaluation of $e)

    ($d, $e) = (2*$d*$e+$a, $e**2-$d**2+$b);
    Tom Melly, tom@tomandlu.co.uk
      The RHS of the assignment is evaluated before either either $d or $e is changed. The intermediate value are saved on Perl's stack.

        Thanks for the heads-up. That's pretty much what I assumed, but it's nice to have it confirmed. I must admit I find precedence a nightmare, and tend to avoid coding that depends on it.

        map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e** 2-$d**2+$b);$c=$d**2+$e**2>4?_:0}1..99;print$c}0..59;print$/}0..20;
        Tom Melly, pm@tomandlu.co.uk
Re^2: Fractal Golf anyone?
by Melly (Chaplain) on Nov 29, 2006 at 12:21 UTC

    Woo-hoo! - 135! (and 134 if I would settle for '_' instead of $")

    Basically, lose the initial assignment to $c, and handle $c via a conditional operator

    map{ $a=1-$_/10; map{ $d=$a; $e=$b=$_/20-2; map{ ($d,$e)=(2*$d*$e+$a,$e**2-$d**2+$b); $c=$d**2+$e**2>4?$":0 }1..99; print$c }0..59; print$/ }0..20;
    Tom Melly, tom@tomandlu.co.uk

      Well, my last version failed to work properly on linux due to v large FP numbers (due to lack of last when the >4 condition is met).

      Here's a slightly longer version (136) that is linux-safe (and still avoids a last).

      map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
      Tom Melly, pm@tomandlu.co.uk