Mandelbrot set: Difference between revisions

Content deleted Content added
Thundergnat (talk | contribs)
→‎{{header|Raku}}: re-enable syntax highlighting
Grondilu (talk | contribs)
→‎{{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((xmin=-8601)) # int(-2.1*4096){
local -ir maxiter=100
((xmax=2867)) # int( 0.7*4096)
local -i i j {x,y}m{in,ax} d{x,y}
local -ra C=( {0..9} )
((ymin=-4915)) # int(-1.2*4096)
local -i lC=${#C[*]}
((ymax=4915)) # int( 1.2*4096)
local -i columns=${COLUMNS:-72} lines=${LINES:-24}
 
((
((maxiter=30))
xmin=-21*4096/10,
xmax= 7*4096/10,
ymin=-12*4096/10,
ymax= 12*4096/10,
 
(( dx=(xmax-xmin)/72))columns,
(( dy=(ymax-ymin)/24))lines
))
 
for ((cy=ymax;cy>, i=ymin0; i<lines; cy-=dy, i++)) ; do
C='0123456789'
do for ((cx=xmin, j=0;cx j<=xmaxcolumns; cx+=dx, j++)) ; do
((lC=${#C}))
do (( x=0, y=0, x2=0, y2=0 ))
 
for (( iter=0; iter<maxiter && x2+y2<=16384; iter++ )) ; do
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,
((y=((x*y)>>11)+cy,x=x2-y2+cx,x2=(x*x)>>12,y2=(y*y)>>12))
x2=(x*x)>>12,
done
y2=(y*y)>>12
((c=iter%lC))
))
echo -n ${C:$c:1}
done
((c=iter%lC))
echo
echo -n "${C:$[c:1]}"
done</syntaxhighlight>
done
echo
done
done}</syntaxhighlight>
 
{{out}}