RosettaCodeData/Task/Arithmetic-Complex/Sidef/arithmetic-complex.sidef

14 lines
487 B
Text
Raw Permalink Normal View History

2017-09-23 10:01:46 +02:00
var a = 1:1 # Complex(1, 1)
var b = 3.14159:1.25 # Complex(3.14159, 1.25)
2016-12-05 23:44:36 +01:00
[ a + b, # addition
a * b, # multiplication
-a, # negation
2017-09-23 10:01:46 +02:00
a.inv, # multiplicative inverse
a.conj, # complex conjugate
2016-12-05 23:44:36 +01:00
a.abs, # abs
a.sqrt, # sqrt
b.re, # real
b.im, # imaginary
].each { |c| say c }