1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
module AufgabeFFP1
where
-- calculates 2^ with each element of the continuous list
pof2s :: [Integer]
pof2s = map (2^) [0,1..]
-- alternate:
-- pof2s :: [Integer]
-- pof2s = iterate (2*) 1
-------------------------------------------------------------------------------
-- iterate steps:
-- (1) [1]
-- (2) zipWith (+) ([0,1]) ([1,0]) = [1,1]
-- (3) zipWith (+) ([0,1,1]) ([1,1,0]) = [1,2,1]
-- (4) zipWith (+) ([0,1,2,1]) ([1,2,1,0]) = [1,3,3,1]
-- ...
pd :: [[Integer]]
pd = iterate (\row -> zipWith (+) ([0] ++ row) (row ++ [0])) [1]
|