Add all the A tasks
This commit is contained in:
parent
2dd7375f96
commit
051504d65b
1608 changed files with 18584 additions and 0 deletions
14
Task/Arithmetic-Complex/Haskell/arithmetic-complex-1.hs
Normal file
14
Task/Arithmetic-Complex/Haskell/arithmetic-complex-1.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)
|
||||
8
Task/Arithmetic-Complex/Haskell/arithmetic-complex-2.hs
Normal file
8
Task/Arithmetic-Complex/Haskell/arithmetic-complex-2.hs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
*Main> main
|
||||
Add: 5.0 :+ 2.0
|
||||
Subtract: (-3.0) :+ 2.0
|
||||
Multiply: 4.0 :+ 8.0
|
||||
Divide: 0.25 :+ 0.5
|
||||
Negate: (-1.0) :+ (-2.0)
|
||||
Inverse: 0.2 :+ (-0.4)
|
||||
Conjugate:1.0 :+ (-2.0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue