#!/usr/bin/perl
# ASCII generation of the Mandelbrot set.
# See also:
sub
mandelbrot {
my
(
$z
,
$c
) =
@_
[0, 0];
for
(1 .. 20) {
$z
=
$z
*
$z
+
$c
;
return
$_
if
abs
(
$z
) > 2;
}
}
for
(
my
$y
= 1 ;
$y
>= -1 ;
$y
-= 0.05) {
for
(
my
$x
= -2 ;
$x
<= 0.5 ;
$x
+= 0.0315) {
mandelbrot(
$x
+
$y
* i) ?
' '
:
'#'
;
}
"\n"
;
}