aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2023-03-10 17:04:45 +0100
committerJan Sucan <jan@jansucan.com>2023-03-10 17:04:45 +0100
commit7c51cdee370b0192b44cfa478a49cbcce670fc24 (patch)
tree73510ca227139fb7fcedafbc2891da03944a9209
parentb261f475cdec2b4646f1cf6a1c58cbd174f3500f (diff)
3_b_2: Add solution
-rw-r--r--README.md2
-rw-r--r--ch03/3_b_1.hs8
2 files changed, 7 insertions, 3 deletions
diff --git a/README.md b/README.md
index 113edbb..2b028e4 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,7 @@ more visible in the list the first exercise of a group is in bold italics.
| **_3_a_1_** | yes | 60 | 3. Defining types, streamlining functions |
| 3_a_2 | yes | | |
| **_3_b_1_** | yes | 69 | |
-| 3_b_2 | | | |
+| 3_b_2 | yes, in 3_b_1 | | |
| 3_b_3 | | | |
| 3_b_4 | | | |
| 3_b_5 | | | |
diff --git a/ch03/3_b_1.hs b/ch03/3_b_1.hs
index 4db9c0c..564b6be 100644
--- a/ch03/3_b_1.hs
+++ b/ch03/3_b_1.hs
@@ -1,6 +1,10 @@
--- Write a function that computes the number of elements in a list. To test it,
--- ensure that it gives the same answers as the standard length function.
+-- 1. Write a function that computes the number of elements in a list. To test
+-- it, ensure that it gives the same answers as the standard length function.
+--
+-- 2. Add a type signature for your function to your source file. To test it,
+-- load the source file into ghci again.
+myLength :: [a] -> Int
myLength (x:xs) = 1 + myLength xs
myLength [] = 0