Mandelbrot set: Difference between revisions

Content deleted Content added
PureFox (talk | contribs)
m →‎{{header|Wren}}: Changed to Wren S/H
Chkas (talk | contribs)
 
(14 intermediate revisions by 4 users not shown)
Line 1,915:
==={{header|AmigaBASIC}}===
{{trans|QBasic}}
[[File:Amigabasic mandelbrot.png|thumb|Output]]
 
<syntaxhighlight lang="amigabasicqbasic">SCREEN 1,320,200,5,1
WINDOW 2,"Mandelbrot",,0,1
 
Line 1,964:
WHILE (1)
WEND</syntaxhighlight>
 
==={{header|Applesoft BASIC}}===
 
Line 2,466 ⟶ 2,467:
==={{header|Locomotive Basic}}===
{{trans|QBasic}}
[[File:Cpcbasic mandelbrot.png|thumb|CPCBasic output]]
This program is meant for use in [https://benchmarko.github.io/CPCBasic/cpcbasic.html CPCBasic] specifically, where it draws a 16-color 640x400 image in less than a minute. (Real CPC hardware would take far longer than that and has lower resolution.)
<syntaxhighlight lang="locobasicbasic">1 MODE 3 ' Note the CPCBasic-only screen mode!
2 FOR xp = 0 TO 639
3 FOR yp = 0 TO 399
Line 5,016 ⟶ 5,018:
 
=={{header|Dart}}==
Implementation in Google Dart, works on httphttps://try.dartlang.org/ (as of 10/18/2011) since the language is very new, it may break in the futuredartpad.dev
The implementation uses aan incomplete Complex class supporting operator overloading.
<syntaxhighlight lang="dart">class Complex {
class Complex {
double _r, _i;
 
Complex(this._r, this._i);
double get r => _r;
double get i => _i;
String toString() => "($r,$i)";
 
Complex operator +(Complex other) => new Complex(r + other.r, i + other.i);
Complex operator *(Complex other) =>
new Complex(r * other.r - i * other.i, r * other.i + other.r * i);
double abs() => r * r + i * i;
}
 
void main() {
doubleconst startX start_x= -1.5;
doubleconst startY start_y= -1.0;
doubleconst stepX step_x= 0.03;
doubleconst stepY step_y= 0.1;
 
for (int y = 0; y < 20; y++) {
String line = "";
for (int x = 0; x < 70; x++) {
Complexvar c =new Complex(start_xstartX +step_x stepX * x,start_y startY +step_y stepY * y);
Complexvar z =new Complex(0.0, 0.0);
for (int i = 0; i < 100; i++) {
z = z *( z) + c;
if (z.abs() > 2) {
break;
}
}
line += z.abs() > 2 ? " " : "*";
}
print(line);
}
}
}</syntaxhighlight>
 
}</syntaxhighlight>
 
=={{header|Dc}}==
Line 5,225 ⟶ 5,230:
=={{header|EasyLang}}==
 
[https://easylang.devonline/apps/mandelbrot.html Run it]
 
<syntaxhighlight lang="easylang">
# Mandelbrot
#
res = 4
maxiter = 200
Line 5,641 ⟶ 5,644:
 
===Graphical version===
[[File:Mandelbrot emacs lisp.png|thumb|Output]]
With a few modifications (mandel-size, mandel-iter, string-to-image, mandel-pic), the code above can also render the Mandelbrot fractal to an XPM image and display it directly in the buffer. (You might have to scroll up in Emacs after the function has run to see its output.)
<syntaxhighlight lang="lisp">; === Graphical Mandelbrot ============================================
Line 12,454 ⟶ 12,458:
# for which the sequence z[n+1] := z[n] ** 2 + z[0] (n >= 0) is bounded.
# Since this program is computing intensive it should be compiled with
# hi comps7c -O2 mandelbr
 
const integer: pix is 200;
Line 12,486 ⟶ 12,490:
z0 := center + complex(flt(x) * zoom, flt(y) * zoom);
point(x + pix, y + pix, colorTable[iterate(z0)]);
end for;
end for;
end func;
Line 12,504 ⟶ 12,508:
end for;
displayMandelbrotSet(complex(-0.75, 0.0), 1.3 / flt(pix));
DRAW_FLUSHflushGraphic;
readln(KEYBOARD);
end func;
Line 13,564 ⟶ 13,568:
 
0 OK, 0:1726 </pre>
 
=={{header|Uiua}}==
 
<syntaxhighlight lang="uiua">
Size ← 800
Cs ← ÷ 5[5_5_5 4_5_5 4_5_5 3_5_5 5_3_5 3_3_5 2_5_0 5_2_2 2_2_5 0_0_0]
# Initialise complex co-ordinates.
×2.5 ⊞ℂ:-1/4. ÷:-÷2,⇡.⟜(↯:0⊟.)Size
# Iterate 50 times (a, b, got_there) -> (a*a+b, b, got_there)
# got_there counts when corresponding value in b hits 2.
⍥⊃(+×.|⋅∘|+<2⌵⊙◌)50 0
# Scale the results down and display
⊏:Cs⌈×9÷:⟜(/↥/↥)ₙ2◌◌
 
</syntaxhighlight>
{{out}}
[[File:Uiua Mandelbrot Set.png|thumb|center]]
 
=={{header|UNIX Shell}}==
Line 14,332 ⟶ 14,353:
 
var Game = MandelbrotSet.new(800, 600)</syntaxhighlight>
 
{{out}}
[[File:Wren-Mandelbrot_set.png|400px]]
 
=={{header|XPL0}}==