Give the type and value of each of the following expressions. For example, given the expression 2+2, the answer should be written as 4 :: Int. Note, some expressions may be errors.
1 + sqrt 9 * 4 + 13
"asfd" ++ "dfsa"
"a" : "dfsa
[‘a’] ++ [‘d’,’f’,’s’,’a’]
[20,30..100]
sum [1..10]
let x = 5 in x*(x+1)
1:(take 1 [1,2])
[[1,2],[3,4]]
Given the following definition of the function f, simplify the expression f (f 1 2) (f 3 4), showing all your steps.
f :: Int -> Int -> Int
f x y = 2*x + 3
Write a function isLetter :: Char -> Bool that determines whether its argument is a letter of the alphabet.
Write a function capitalise :: String -> String that makes all the letters upper case.
Write a function that determines whether or not one string is the prefix of another string.
Write a function that occurs :: Int -> [Int] -> Int that returns the number of times a given number occurs in a list.
Write a function reverse that reverses a string.
Write a function palindrome :: String -> Bool that determines whether its argument is a palindrome. A palindrome is a string which is the same when you reverse it; for example, ‘abccba’ is a palindrome, but ‘abcca’ is not.