Skip to content

Commit 62711fa

Browse files
committed
Update my answers in ch3
1 parent 7755d79 commit 62711fa

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

ch3/ex1.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
Exercises: Scope
2+
13
1. Yes, y is in scope for z.
2-
2. No, h is not in scope for g.
4+
2. No, h is not in scope for g. h is not even defined.
35
3. No, everything needed to execute area is not in scope. The d used to compute
46
the radius is not in scope. See ex1.hs.
57
4. Yes, everything needed to execute area is in scope. See ex1.hs.

ch3/ex3.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Reading syntax
55
a) concat [[1, 2, 3], [4, 5, 6]], is ok
66
b) ++ [1, 2, 3] [4, 5, 6] should be (++) [1, 2, 3] [4, 5, 6]
77
c) (++) "hello" " world" is ok
8-
d) ["hello" ++ " world] should be "hello" ++ " world"
8+
d) ["hello" ++ " world] should be ["hello" ++ " world"]
99
e) 4 !! "hello" should be "hello" !! 4
1010
f) (!!) "hello" 4 is ok
1111
g) take "4 lovely" should be take 4 "lovely"

ch3/print3broken.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
module Print3Broken where
22

3+
-- To make it compile
4+
-- 1. Define greeting at the top-level
5+
greeting :: String
6+
greeting ="Yarrrrr"
7+
38
printSecond :: IO ()
49
printSecond = do
510
putStrLn greeting -- Not in scope: 'greeting'
@@ -8,4 +13,5 @@ main :: IO ()
813
main = do
914
putStrLn greeting
1015
printSecond
11-
where greeting = "Yarrrrr"
16+
-- 2. This can be commented out
17+
-- where greeting = "Yarrrrr"

0 commit comments

Comments
 (0)