Skip to content

Commit 7755d79

Browse files
committed
Update my answers in ch2
1 parent 20f8aa9 commit 7755d79

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

ch2/ex1.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Exercises: Comprehension Check
2+
13
1.
24

35
Given,
@@ -7,9 +9,13 @@ square x = x * x
79

810
Then, in the REPL we write them as
911

10-
let half x = x /2
12+
let half x = x / 2
1113
let square x = x * x
1214

1315
2.
1416

1517
areaOfCircle r = 3.14 * (r * r)
18+
19+
3.
20+
21+
areaOfCircle r = pi * (r * r)

ch2/ex2.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Exercises: Parentheses and Association
2+
13
1.
24

35
a) 8 + 7 * 9 = 8 + (7 * 9) = 71

ch2/ex3.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
Exercises: Heal the Sick
2+
13
1. let area x = 3.14 * (x * x)
24

35
2. let double x = x * 2
46

7+
or
8+
9+
let double b = b * 2
10+
511
3.
612

713
x = 7

ch2/ex4.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Exercises: A Head Code
2+
13
1. let x = 5 in x; 5
24
2. let x = 5 in x * x; 25
35
3. let x = 5; y = 6 in x * y; 30

ch2/learn.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- learn.hs
2+
3+
module Learn where
4+
-- First, we declare the name of our module so
5+
-- it can be imported by name in a project.
6+
-- We won't be doing a project of this size
7+
-- for a while yet.
8+
9+
x = 10 * 5 + y
10+
11+
myResult = x * 5
12+
13+
y = 10

0 commit comments

Comments
 (0)