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
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.
6. Mergesort
Write a function that sorts a list using mergesort.
A linear congruential generator is a formula for generating a series of pseudorandom numbers. It has the form
Xn+1 = (a Xn + c) mod m
where X is the series of pseudorandom values, and a, c, and m are constants.
Use a linear congruential generator to construct
an infinite list of values of type Double
in the range
from 0.0 to 1.0. Use the constants
a = 1,664,525
c = 1,013,904,223
m = 232