Haskell — Functions with lists

In this problem you have to define some functions about lists in
Haskell.

1.  Define a function myLength :: [Int] -> Int that, given a list of
    integers, returns its length.

2.  Define a function myMaximum :: [Int] -> Int that, given a non-empty
    list of integers, returns its maximal element.

3.  Define a function average :: [Int] -> Float that, given a non-empty
    list of integers, returns its average.

4.  Define a function buildPalindrome :: [Int] -> [Int] that, given a
    list, returns its palindrome that starts with the reserved list.

5.  Define a function remove :: [Int] -> [Int] -> [Int] that given a
    list of integers x and a list of integers y, returns x after having
    removed all the ocurrences of the elements in y.

6.  Define a function flatten :: [[Int]] -> [Int] that flattens a list
    of lists yielding a single list of elements.

7.  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.

8.  Define a function primeDivisors :: Int -> [Int] that returns the
    list of prime divisors of a non-zero natural.

Scoring

Esch function scores 12 points and the sample 4.

Problem information

Author: Unknown
Translator: Jordi Petit

Generation: 2026-02-03T17:04:27.770Z

© Jutge.org, 2006–2026.
https://jutge.org
