FP Laboratory 5
Jump to navigation
Jump to search
List comprehension
Using the list comprehension implement following functions:
- Create a function that generates a list of all odd numbers in given interval.
oddList :: Int -> Int -> [Int]
- Create a function that takes a string and converts all characters to upper case letters.
allToUpper :: String -> String
- Create a function that removes all upper case letters from a string.
removeAllUpper :: String -> String
- Create functions that computes union and intersection of two sets.
union :: [a] -> [a] -> [a]
intersection :: [a] -> [a] -> [a]
More complex functions
- Create a function that count the number of occurrences of all characters from a given string.
countThem :: String -> [(Char, Int)]
*Main>countThem "hello hello hello"
[('h',3),('e',3),('l',6),('o',3),(' ',2)]