Mandelbrot set: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) →{{header|Raku}}: re-enable syntax highlighting |
→{{header|UNIX Shell}}: cleaning and try to use COLUMNS and LINES |
||
Line 13,460:
=={{header|UNIX Shell}}==
{{works with|Bourne Again SHell|4}}
<syntaxhighlight lang="bash">function mandelbrot(
local -ir maxiter=100
local -i i j {x,y}m{in,ax} d{x,y}
local -ra C=( {0..9} )
local -i lC=${#C[*]}
local -i columns=${COLUMNS:-72} lines=${LINES:-24}
((
xmin=-21*4096/10,
xmax= 7*4096/10,
ymin=-12*4096/10,
ymax= 12*4096/10,
))
▲for((cy=ymax;cy>=ymin;cy-=dy)) ; do
do
▲ for((cx=xmin;cx<=xmax;cx+=dx)) ; do
((
▲ ((x=0,y=0,x2=0,y2=0))
y=((x*y)>>11)+cy,
▲ for((iter=0;iter<maxiter && x2+y2<=16384;iter++)) ; do
x=x2-y2+cx,
x2=(x*x)>>12,
done▼
y2=(y*y)>>12
((c=iter%lC))▼
))
echo -n ${C:$c:1}▼
echo▼
done</syntaxhighlight>▼
done
{{out}}
|