Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
var x = math.complex(-2, 3);
x = math.multiply(x, math.i);
JS has no built-in complex numbers. The math.js library was used in this example.
complex :: x
x = (-2,3)
x = x * (0,1)
let i = ( 0 :+ 1 ) ; x = 3 * i - 2 in x * i
x = (0 :+ 1) * ((0 - 2) :+ 3)
Declaration and initialization is not required in Haskell.
As prefix negation in Haskell is tricky, I've used (0 - 2) for (-2).
Haskell variables are immutable, therefore "multiply it by two" is both unnecessary and too complicated.
As prefix negation in Haskell is tricky, I've used (0 - 2) for (-2).
Haskell variables are immutable, therefore "multiply it by two" is both unnecessary and too complicated.
Complex x = new Complex(-2.0, 3.0);
x = x.multiply(Complex.I);
This uses the Apache Commons Math library.
(let ((x #c(-2 3)))
(* x #c(0 1)))
x = 3j-2
y = x * 1j
x = 3i - 2
x *= 1i
(define x -2+3i)
(display (* x 0+1i))
Most Schemes have a specialized reader syntax for complex numbers.