30 lines
547 B
Text
30 lines
547 B
Text
use fmt;
|
|
use math;
|
|
|
|
type complex = struct {
|
|
re: f64,
|
|
im: f64
|
|
};
|
|
|
|
export fn main() void = {
|
|
for (let y = -1.2; y < 1.2; y += 0.05) {
|
|
for (let x = -2.05; x < 0.55; x += 0.03) {
|
|
let z = complex {re = 0.0, im = 0.0};
|
|
|
|
for (let m = 0z; m < 100; m += 1) {
|
|
let tz = z;
|
|
|
|
z.re = tz.re*tz.re - tz.im*tz.im;
|
|
z.im = tz.re*tz.im + tz.im*tz.re;
|
|
z.re += x;
|
|
z.im += y;
|
|
};
|
|
fmt::print(if (abs(z) < 2f64) '#' else '.')!;
|
|
};
|
|
fmt::println()!;
|
|
};
|
|
};
|
|
|
|
fn abs(z: complex) f64 = {
|
|
return math::sqrtf64(z.re*z.re + z.im*z.im);
|
|
};
|