-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmandelbrot.kal
47 lines (37 loc) · 1.14 KB
/
mandelbrot.kal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Already defined in basiclib
# def unary- (v)
# 0 - v
# def binary> 10 (lhs rhs)
# rhs < lhs
# def binary: 1 (x y)
# y
# def binary| 5 (lhs rhs)
# if lhs then 1 else if rhs then 1 else 0
def printdensity(d)
if d > 8 then
putchard(32) # ' '
else if d > 4 then
putchard(46) # '.'
else if d > 2 then
putchard(43) # '+'
else
putchard(42) # '*'
def mandelconverger(real imag iters creal cimag)
if iters > 255 | (real*real + imag*imag > 4) then
iters
else
mandelconverger(
real*real - imag*imag + creal,
2*real*imag + cimag,
iters+1, creal, cimag)
def mandelconverge(real imag)
mandelconverger(real, imag, 0, real, imag)
def mandelhelp(xmin xmax xstep ymin ymax ystep)
for y = ymin, y < ymax, y + ystep in (
(for x = xmin, x < xmax, x + xstep in
printdensity(mandelconverge(x, y)))
: putchard(10))
def mandel(realstart imagstart realmag imagmag)
mandelhelp(realstart, realstart+realmag*78, realmag,
imagstart, imagstart+imagmag*48, imagmag)
mandel(-2.3, -1.3, 0.05, 0.07)