2024-07-12 21:01:44 +00:00
|
|
|
width := 80
|
|
|
|
|
height := 24
|
|
|
|
|
maxiter := 100
|
|
|
|
|
|
|
|
|
|
V+ := { a1::b1 a2::b2 ->
|
|
|
|
|
(+ a1 a2)::(+ b1 b2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
V* := { a1::b1 a2::b2 ->
|
|
|
|
|
(- (* a1 a2) (* b1 b2))::(+ (* a1 b2) (* b1 a2))
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-30 16:15:28 +00:00
|
|
|
Vsquared := { x -> V* x x }
|
2024-07-12 21:01:44 +00:00
|
|
|
|
2025-04-30 16:15:28 +00:00
|
|
|
Vsquared-abs := { a::b ->
|
2024-07-12 21:01:44 +00:00
|
|
|
+ (* a a) (* b b)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mandel := {
|
|
|
|
|
0 _ _ -> true
|
2025-04-30 16:15:28 +00:00
|
|
|
_ _ _?(has Vsquared-abs > 4) -> false
|
|
|
|
|
n c z -> mandel (-- n) c (V+ (Vsquared z) c)
|
2024-07-12 21:01:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mindim := if (< width height) {width} {height}
|
|
|
|
|
scale := / 2 mindim
|
|
|
|
|
iterdim := { dim body ->
|
|
|
|
|
half := / dim 2
|
|
|
|
|
for (- half) half { x ->
|
|
|
|
|
body (* scale x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iterdim height { b ->
|
|
|
|
|
line := ""
|
|
|
|
|
iterdim width { a ->
|
|
|
|
|
line = & line (if (mandel maxiter a::b 0::0) {"#"} {" "})
|
|
|
|
|
}
|
|
|
|
|
gc 'collect
|
|
|
|
|
print line
|
|
|
|
|
}
|