From fe4b4262e0d62b454c91d99a8c9cd4568fdd49d1 Mon Sep 17 00:00:00 2001 From: Jan Sucan Date: Wed, 8 Mar 2023 19:29:29 +0100 Subject: 2_b_1: Add solution --- README.md | 2 +- ch02/2_b_1.txt | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 ch02/2_b_1.txt diff --git a/README.md b/README.md index c2f8d5d..743333c 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ more visible in the list the first exercise of a group is in bold italics. | 1_a_3 | yes | | | | 1_a_4 | yes | | | | **_2_a_1_** | yes | 25 | 2. Types and functions | -| **_2_b_1_** | | 39 | | +| **_2_b_1_** | yes | 39 | | | 2_b_2 | | | | | 2_b_3 | | | | | **_3_a_1_** | | 60 | 3. Defining types, streamlining functions | diff --git a/ch02/2_b_1.txt b/ch02/2_b_1.txt new file mode 100644 index 0000000..839e172 --- /dev/null +++ b/ch02/2_b_1.txt @@ -0,0 +1,17 @@ +-- Haskell provides a standard function, last :: [a] -> a, that returns the last +-- element of a list. From reading the type alone, what are the possible valid +-- behaviours (omitting crashes and infinite loops) that this function could +-- have? What are a few things that this function clearly cannot do? + +-- Possible valid behaviours could be +-- - returning the first element of the list +-- - returning an element in the middle of the list +-- - returning the last element of the list +-- ... + +-- This function clearly cannot +-- - return an element of the list at a specified index because it has just +-- one parameter +-- - return a sublist of the list +-- - be an identity function (return its argument) +-- ... -- cgit v1.2.3