Fixing Errors:
concat [[1, 2, 3], [4, 5, 6]]
-- Working
++ [1, 2, 3] [4, 5, 6]
-- Incorrect (infix used as prefix). Fix:
(++) [1, 2, 3] [4, 5, 6]
(++) "hello" " world"
-- Working
["hello" ++ " world]
-- Incorrect (missing closing "). Fix:
["hello" ++ " world"]
4 !! "hello"
-- Incorrect (order of arguments). Fix:
"hello" !! 4
(!!) "hello" 4
-- Working
take "4 lovely"
-- Incorrect (placement of opening "). Fix:
take 4 "lovely"
take 3 "awesome"
-- Working
Pair code with result
-- a) - d)
concat [[1 * 6], [2 * 6], [3 * 6]]
[6,12,18]
-- b) - c)
"rain" ++ drop 2 "elbow"
"rainbow"
-- c) - e)
10 * head [1, 2, 3]
10
-- d) - a)
(take 3 "Julie") ++ (tail "yes")
"Jules"
-- e) - b)
concat [tail [1, 2, 3], tail [4, 5, 6], tail [7, 8, 9]]
[2,3,5,6,8,9]
-
String/list manipulation functions (includes 1 and 2)
link:ch03_3.8_1.hs[role=include]
-
thirdLetter
link:ch03_3.8_2.hs[role=include]
-
Letter index
link:ch03_3.8_3.hs[role=include]
-
Reverse function using
drop
andtake
(for fixed input)
link:ch03_3.8_4.hs[role=include]
-
Extension of previous
link:ch03_3.8_5.hs[role=include]