From 32af1594520d1ce6f4166a8da5a8635d636968ed Mon Sep 17 00:00:00 2001 From: Jan Sucan Date: Thu, 9 Mar 2023 20:50:49 +0100 Subject: 2_b_3: Add solution --- ch02/2_b_3.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 ch02/2_b_3.txt (limited to 'ch02/2_b_3.txt') diff --git a/ch02/2_b_3.txt b/ch02/2_b_3.txt new file mode 100644 index 0000000..2b818de --- /dev/null +++ b/ch02/2_b_3.txt @@ -0,0 +1,14 @@ +-- Load your lastButOne function into ghci, and try it out on lists of different +-- lengths. What happens when you pass it a list that's too short? + +ghci> :l 2_b_2.hs +[1 of 1] Compiling Main ( 2_b_2.hs, interpreted ) +Ok, one module loaded. +ghci> lastButOne [1, 2, 3, 4] +3 +ghci> lastButOne [1, 2, 3] +2 +ghci> lastButOne [1, 2] +1 +ghci> lastButOne [1] +*** Exception: Prelude.tail: empty list -- cgit v1.2.3