val conjugate = fn(c) { if c is not complex: throw "expected complex number" return complex(c[1], -c[2]) } val examples = { "-(1+1i)": -(1+1i), "abs(1+1i)": abs(1+1i), "(2+2i) + (5+13.2i)": (2+2i) + (5+13.2i), "5 + (2+2i)": 5 + (2+2i), "5i + (2+2i)": 5i + (2+2i), "5i - (2+2i)": 5i - (2+2i), "(1+1i) * (3.141592653589793+1.2i)": (1+1i) * (3.141592653589793+1.2i), "(5+3i) / (4-3i)": (5+3i) / (4-3i), "1 / (4-3i)": 1 / (4-3i), "(4-3i) ^ 3": (4-3i) ^ 3, "conjugate(7+21.0i)": conjugate(7+21.0i), } for e of examples { writeln "{{e : 20}}: ", examples[e] }