Implement the following functions using higher-order functions (and other predefined functions) of Haskell without using recursion.
Implement a function flatten :: [[Int]] -> [Int]
that flattens a list of lists of integers in a list of
integers.
Implement a function myLength :: String -> Int
that returns the length of a string.
Implement a function myReverse :: [Int] -> [Int]
that reverses a list of integers.
Implement a function
countIn :: [[Int]] -> Int -> [Int] that, given a list
of sublists
and an element
,
returns the list that tells who many times
appears in each sublist of
.
Implement a function
firstWord :: String -> String that, given a string with
blanks and alphabetic characters, returns its first word.
Each function scores 20 points.
Input
flatten [[1,2,3],[4,5],[6],[],[3,3]] myLength "Albert" myReverse [1..10] countIn [[3,2,3],[3],[], [2,2]] 3 firstWord " Volem pa amb oli "
Output
[1,2,3,4,5,6,3,3] 6 [10,9,8,7,6,5,4,3,2,1] [2,1,0,0] "Volem"