Skip to content

Commit 4ca1081

Browse files
authored
Removed questions about content that I didn't cover
1 parent ec04603 commit 4ca1081

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

Homework02/Solution.hs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ f1 x y z = x ** (y/z)
88
f2 :: Double -> Double -> Double -> Double
99
f2 x y z = sqrt (x/y - z)
1010

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]
1613

1714
f5 :: String -> String -> String -> Bool
1815
f5 x y z = x == (y ++ z)
@@ -56,16 +53,6 @@ v4 = 3.1415 :: Double
5653
v5 = round v4 :: Int
5754

5855
-- 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
6956
-- Can you also define in Haskell list of lists? Did we showed any example of that? How would you access the inner
7057
-- most elements?
7158

0 commit comments

Comments
 (0)