-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweek04.hs
61 lines (51 loc) · 1.46 KB
/
week04.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{-# OPTIONS_GHC -fno-warn-overlapping-patterns #-}
journeyCost :: Float -> Float -> Float
journeyCost miles fuelcostperlitre =
let milespergallon = 35
litrespergallon = 4.55
gallons = miles / milespergallon
in (gallons * litrespergallon * fuelcostperlitre)
sumFee :: Float -> Float
sumFee qty =
let commision = 1.0
in (qty + commision + x + actualPrice)
where
x = 1.0
y = 2.0
actualPrice :: Float
actualPrice = 35.00
priceFilter :: Float -> Float
priceFilter x
| x < actualPrice = x - actualPrice
| otherwise = x
data Symbol = Base | Quote deriving (Show, Read)
data Base = BTC | LTC | BNB deriving (Show, Read)
data Quote = USDT | BUSD | DAI deriving (Show, Read)
symbolTicker :: Base -> Quote -> String
symbolTicker base quote =
case base of
BTC -> "BTC" ++ quote'
LTC -> "LTC" ++ quote'
_ -> "ASSET IS NOT TRADEABLE"
where
quote' = quoteAsset quote
quoteAsset :: Quote -> String
quoteAsset quote =
case quote of
USDT -> "USDT"
DAI -> "DAI"
BUSD -> "BUSD"
_ -> "s"
testMaybe:: () -> String
testMaybe () = let x = (Just Nothing)
in
case x of
(Just _) -> "SOMETHING"
Nothing -> "NON"
helloMonad :: String -> IO String
helloMonad x =
do
putStrLn ("Hello" ++ x)
putStrLn "what's your name ?"
name <- getLine
return name