define(square, { x: Float }, Float, x * x)
define(julia, { zx: Float; zy: Float }, Int,
{
let(cr) = -0.7
let(ci) = 0.27015
let(i) = 0
while(i < 48 and square(zx) + square(zy) < 4.0,
{
let(tmp) = square(zx) - square(zy)
tmp += cr
zy *= 2.0 * zx
zy += ci
zx = tmp
i += 1
}
)
i
}
)
define(render_row, { y: Int }, Null,
{
let(x) = -50
while(x < 50,
{
let(fx) = Float(x) / 30.0
let(fy) = Float(y) / 15.0
let(iter) = julia(fx, fy)
let(str) = " "
if(
[ iter == 48, str = "#" ],
[ 42 < iter, str = "@" ],
[ 36 < iter, str = "%" ],
[ 30 < iter, str = "&" ],
[ 24 < iter, str = "" ],
[ 18 < iter, str = "*" ],
[ 12 < iter, str = "+" ],
[ 8 < iter, str = "=" ],
[ 6 < iter, str = "-" ],
[ 4 < iter, str = "." ]
)
print(str)
x += 1
}
)
print("\n")
}
)
main({ let(y) = -20; while(y < 20, { render_row(y); y += 1 }) })