Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Mandelbrot-set/Picat/mandelbrot-set.picat
Normal file
30
Task/Mandelbrot-set/Picat/mandelbrot-set.picat
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
go =>
|
||||
|
||||
Width = 90,
|
||||
Height = 50,
|
||||
Limit = 50,
|
||||
foreach(Y in 1..Height)
|
||||
P="",
|
||||
foreach (X in 1..Width)
|
||||
Z=complex(0,0),
|
||||
C=complex(2.5*X/Width-2.0,2.0*Y/Height-1.0),
|
||||
J = 0,
|
||||
while (J < Limit, c_abs(Z)<2.0)
|
||||
Z := c_add(c_mul(Z,Z),C),
|
||||
J := J + 1
|
||||
end,
|
||||
if J == Limit then
|
||||
P := P ++ "#"
|
||||
else
|
||||
P := P ++ "."
|
||||
end
|
||||
end,
|
||||
printf("%s\n", P)
|
||||
end,
|
||||
nl.
|
||||
|
||||
% Operations on complex numbers
|
||||
complex(R,I) = [R,I].
|
||||
c_add(X,Y) = complex(X[1]+Y[1],X[2]+Y[2]).
|
||||
c_mul(X,Y) = complex(X[1]*Y[1]-X[2]*Y[2],X[1]*Y[2]+X[2]*Y[1]).
|
||||
c_abs(X) = sqrt(X[1]*X[1]+X[2]*X[2]).
|
||||
Loading…
Add table
Add a link
Reference in a new issue