diff options
| author | Jan Sucan <jan@jansucan.com> | 2023-03-08 19:29:29 +0100 |
|---|---|---|
| committer | Jan Sucan <jan@jansucan.com> | 2023-03-08 19:29:29 +0100 |
| commit | fe4b4262e0d62b454c91d99a8c9cd4568fdd49d1 (patch) | |
| tree | 39f1bbe27dec719ce8a0af43647a0f1d3ce0c7d5 /ch02/2_b_1.txt | |
| parent | c416bdb936f170377eb71868e7b3f59a667819db (diff) | |
2_b_1: Add solution
Diffstat (limited to 'ch02/2_b_1.txt')
| -rw-r--r-- | ch02/2_b_1.txt | 17 |
1 files changed, 17 insertions, 0 deletions
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) +-- ... |
