Qu

complex

Builtin index · Collections & strings

result = complex(re, im)

Input: re, im · Output: result

What it is

re/im are numbers (real and imaginary parts).

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = complex(re, im)
re numbernot documented yet
im numbernot documented yet
result Complex
Returns a Complex. 3 + 4j is the literal form; this is for computed components.

Examples

No documentation example calls this form yet. The Collections & strings chapter is where one belongs.

How it works

complex(re, im) -- the spelled-out constructor. 2i and a + b * 1i build one too, but a function is what a computed pair needs (complex(x[k], y[k])), and the spec has named it since the beginning as the alternative for code that shadows i as a loop variable. It did not exist, so the spec's own first example did not run.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.