In this problem you have to define some functions about lists in Haskell.
Define a function myLength :: [Int] -> Int that,
given a list of integers, returns its length.
Define a function myMaximum :: [Int] -> Int that,
given a non-empty list of integers, returns its maximal
element.
Define a function average :: [Int] -> Float that,
given a non-empty list of integers, returns its average.
Define a function
buildPalindrome :: [Int] -> [Int] that, given a list,
returns its palindrome that starts with the reserved list.
Define a function
remove :: [Int] -> [Int] -> [Int] that given a list
of integers
and a list of integers
,
returns
after having removed all the ocurrences of the elements in
.
Define a function flatten :: [[Int]] -> [Int]
that flattens a list of lists yielding a single list of
elements.
Define a function
oddsNevens :: [Int] -> ([Int],[Int]) that, given a list
of integers, returns two lists: Onw with all the even numbers and one
with all the odd numbers, each of them in the same relative order as in
the original list.
Define a function primeDivisors :: Int -> [Int]
that returns the list of prime divisors of a non-zero natural.
Esch function scores 12 points and the sample 4.
Input
myMaximum [4,3,1,5,4,5,2] average [1,2,3] buildPalindrome [2,4,6] flatten [[2,6],[8,1,4],[],[1]] remove [1,4,5,3,4,5,1,2,7,4,2] [2,4] myLength [1,3..10] oddsNevens [1,4,5,3,4,5,1,2,7,4,2] primeDivisors 255
Output
5 2.0 [6,4,2,2,4,6] [2,6,8,1,4,1] [1,5,3,5,1,7] 5 ([1,5,3,5,1,7],[4,4,2,4,2]) [3,5,17]