Question: Using Haskell 1) Use head and tail to define functionfourth1 :: [a] -> a that returns the fourth item of the input list. 2) Use!!
Using Haskell
1) Use head and tail to define functionfourth1 :: [a] -> a that returns the fourth item of the input list.
2) Use!! and length to define function nthFromLast :: Int -> [a] -> a that receives a number n and a list, and returns nth item of the list from last. For example,nthFromLast 3 [1..7] must return 5.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
