aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2023-03-06 15:37:52 +0100
committerJan Sucan <jan@jansucan.com>2023-03-06 15:37:52 +0100
commitf1ccb49d6c5c30fc422f1eae595cf97615c5cb1a (patch)
tree19f84069203ba1990c0fb48018704cf6e6a83cbf
parent82a52561ae94b2eb550667944284a672ea132c1d (diff)
1_a_1: Add solution
-rw-r--r--README.md2
-rw-r--r--ch01/1_a_1.txt76
2 files changed, 77 insertions, 1 deletions
diff --git a/README.md b/README.md
index 4f6483a..184da7b 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@ more visible in the list the first exercise of a group is in bold italics.
| Exercise | Solved | Page | Chapter |
| -------------- | ------ | ---- | ------- |
-| **_1_a_1_** | | 16 | 1. Getting started |
+| **_1_a_1_** | yes | 16 | 1. Getting started |
| 1_a_2 | | | |
| 1_a_3 | | | |
| 1_a_4 | | | |
diff --git a/ch01/1_a_1.txt b/ch01/1_a_1.txt
new file mode 100644
index 0000000..1f367ab
--- /dev/null
+++ b/ch01/1_a_1.txt
@@ -0,0 +1,76 @@
+-- Enter the following expressions into ghci. What are their types?
+
+ghci> :t 5 + 8
+5 + 8 :: Num a => a
+ghci> 5 + 8
+13
+
+ghci> :t 3 * 5 + 8
+3 * 5 + 8 :: Num a => a
+ghci> 3 * 5 + 8
+23
+
+ghci> :t 2 + 4
+2 + 4 :: Num a => a
+ghci> 2 + 4
+6
+
+ghci> :t (+) 2 4
+(+) 2 4 :: Num a => a
+ghci> (+) 2 4
+6
+
+ghci> :t sqrt 16
+sqrt 16 :: Floating a => a
+ghci> sqrt 16
+4.0
+
+ghci> :t succ 6
+succ 6 :: (Enum a, Num a) => a
+ghci> succ 6
+7
+
+ghci> :t succ 7
+succ 7 :: (Enum a, Num a) => a
+ghci> succ 7
+8
+
+ghci> :t pred 9
+pred 9 :: (Enum a, Num a) => a
+ghci> pred 9
+8
+
+ghci> :t pred 8
+pred 8 :: (Enum a, Num a) => a
+ghci> pred 8
+7
+
+ghci> :t sin (pi / 2)
+sin (pi / 2) :: Floating a => a
+ghci> sin (pi / 2)
+1.0
+
+ghci> :t truncate pi
+truncate pi :: Integral b => b
+ghci> truncate pi
+3
+
+ghci> :t round 3.5
+round 3.5 :: Integral b => b
+ghci> round 3.5
+4
+
+ghci> :t round 3.4
+round 3.4 :: Integral b => b
+ghci> round 3.4
+3
+
+ghci> :t floor 3.7
+floor 3.7 :: Integral b => b
+ghci> floor 3.7
+3
+
+ghci> :t ceiling 3.3
+ceiling 3.3 :: Integral b => b
+ghci> ceiling 3.3
+4