in reply to Refactoring: Better Variable Names For Better Understanding? [SOLVED]

I'd re-work that like this:

use constant LIMIT => 20; ## It's a constant. (Should do the same for +4) my @palette = Imager::Color->new( 0,0,0 ); ## Set the first color to b +lack avoids the need for $div ... my ( $re_z, $im_z, iterations ) = (0) x 3; while ( 1 ) { my $saved = $re_z; ## It's just saving a value for use lat +er in the calculation; $temp might also do. $re_z = $re_z * $re_z - $im_z * $im_z + $re_c; $im_z = 2 * $saved * $im_z + $im_c; ++$iterations; last if $re_z * $re_z + $im_z * $im_z > 4; ## Exit and use + the iteration count to pick a color $iterations = 0, last if $iterations == LIMIT; ## beyond t +he limit, set the iterations to 0 to pick black. } $image->setpixel( x => $x, y => $y, color => $palette[ $iterat +ions ] )

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Replies are listed 'Best First'.
Re^2: Refactoring: Better Variable Names For Better Understanding?
by karlgoethebier (Abbot) on Jun 05, 2015 at 07:16 UTC

    Thank you very much for advice BrowserUK and best regards,

    Karl

    «The Crux of the Biscuit is the Apostrophe»