File tree Expand file tree Collapse file tree 1 file changed +2
-15
lines changed Expand file tree Collapse file tree 1 file changed +2
-15
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,8 @@ f1 x y z = x ** (y/z)
8
8
f2 :: Double -> Double -> Double -> Double
9
9
f2 x y z = sqrt (x/ y - z)
10
10
11
- f3 :: Char -> Double -> String -> String
12
- f3 x y z = x: ((show y) ++ z)
13
-
14
- f4 :: Double -> Double -> Bool -> [Bool ]
15
- f4 x y z = [x > y] ++ [z]
11
+ f3 :: Bool -> Bool -> [Bool ]
12
+ f3 x y = [x == True ] ++ [y]
16
13
17
14
f5 :: String -> String -> String -> Bool
18
15
f5 x y z = x == (y ++ z)
@@ -56,16 +53,6 @@ v4 = 3.1415 :: Double
56
53
v5 = round v4 :: Int
57
54
58
55
-- Question 6
59
- -- How would you write the prod function from our lesson so that it works for Int and Double? Does the code compile?
60
-
61
- -- You can write it as following. But you need to use a type class constraint in the type signature of your function.
62
- -- The constraint is the "Num a =>" that tells haskell "a" can be only of certain types that implement the Num class
63
- -- for which the multiplication function (*) is defined. Without this, the compilation would give an error. We will
64
- -- learn more about type classes in lesson "Intro to type classes".
65
- prod :: Num a => a -> a -> a
66
- prod x y = x * y
67
-
68
- -- Question 7
69
56
-- Can you also define in Haskell list of lists? Did we showed any example of that? How would you access the inner
70
57
-- most elements?
71
58
You can’t perform that action at this time.
0 commit comments