The goal of this problem is to work the definition of infinite lists. In particular, you are required to define functions that generate infinite lists to:
Generate the sequence of ones .
Generate the sequence of the natural numbers .
Generate the sequence of the integer numbers .
Generate the sequence of the triangular numbers: .
Generate the sequence of the factorial numbers: .
Generate the sequence of the Fibonacci numbers: .
Generate the sequence of prime numbers: .
Generate the ordered sequence of the Hamming numbers: . The Hamming numbers are those that only have 2, 3 and 5 as prime divisors.
Generate the look-and-say sequence: .
Generate the sequences of rows of the Tartaglia triangle (also known as Pascal’s triangle): .
Define the following functions:
ones :: [Integer]
nats :: [Integer]
ints :: [Integer]
triangulars :: [Integer]
factorials :: [Integer]
fibs :: [Integer]
primes :: [Integer]
hammings :: [Integer]
lookNsay :: [Integer]
tartaglia :: [[Integer]]
In this problem you cannot use infinite enumerations such as , but you are advised to use higer-order functions such as map, scanl, iterate, filter, ...
Each function score 10 points.
Input
take 8 ones take 8 nats take 8 ints take 8 triangulars take 8 factorials take 8 fibs take 8 primes take 8 hammings take 8 lookNsay take 6 tartaglia
Output
[1,1,1,1,1,1,1,1] [0,1,2,3,4,5,6,7] [0,1,-1,2,-2,3,-3,4] [0,1,3,6,10,15,21,28] [1,1,2,6,24,120,720,5040] [0,1,1,2,3,5,8,13] [2,3,5,7,11,13,17,19] [1,2,3,4,5,6,8,9] [1,11,21,1211,111221,312211,13112221,1113213211] [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1],[1,5,10,10,5,1]]