What are the types of these functions?
triple x = 3 * x
even x = (x `mod` 2 == 0)
palindrome xs = (reverse xs == xs)
f x =
f x
2. Mergesort
Write a function that sorts a list using mergesort.
Write a function that sorts a list using quicksort.
Write a function add_vec
that adds
two vectors represented as lists. Give your function the most general
possible type.
Write a function dot
that computes
the dot product of two vectors represented as lists.
Write a function add
that
adds two matrices represented as lists of lists.
Construct an infinite list allPairs
that contains all pairs of positive integers. Every pair must appear
exactly once in the list.
The RealFrac
type class includes a function floor
that
rounds a value down to the nearest integer:
floor :: (RealFrac a, Integral b) => a -> b
Assume
that floor
is not predefined, and write it yourself.