Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Arithmetic-Complex/Haskell/arithmetic-complex.hs
Normal file
14
Task/Arithmetic-Complex/Haskell/arithmetic-complex.hs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import Data.Complex
|
||||
|
||||
main = do
|
||||
let a = 1.0 :+ 2.0 -- complex number 1+2i
|
||||
let b = 4 -- complex number 4+0i
|
||||
-- 'b' is inferred to be complex because it's used in
|
||||
-- arithmetic with 'a' below.
|
||||
putStrLn $ "Add: " ++ show (a + b)
|
||||
putStrLn $ "Subtract: " ++ show (a - b)
|
||||
putStrLn $ "Multiply: " ++ show (a * b)
|
||||
putStrLn $ "Divide: " ++ show (a / b)
|
||||
putStrLn $ "Negate: " ++ show (-a)
|
||||
putStrLn $ "Inverse: " ++ show (recip a)
|
||||
putStrLn $ "Conjugate:" ++ show (conjugate a)
|
||||
Loading…
Add table
Add a link
Reference in a new issue