diff options
| author | manuel <manuel@mausz.at> | 2012-03-23 17:44:30 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2012-03-23 17:44:30 +0100 |
| commit | af2639ac7e4bd714fae65fbe17ccb1177f0e2abb (patch) | |
| tree | 8da88c4c9640b32583cf34813c65966c9ccef73b /AufgabeFFP1.hs | |
| parent | d772ddd6979fc88d3e6e5255bb23850b64688111 (diff) | |
| download | ffp-af2639ac7e4bd714fae65fbe17ccb1177f0e2abb.tar.gz ffp-af2639ac7e4bd714fae65fbe17ccb1177f0e2abb.tar.bz2 ffp-af2639ac7e4bd714fae65fbe17ccb1177f0e2abb.zip | |
implement pd
Diffstat (limited to 'AufgabeFFP1.hs')
| -rw-r--r-- | AufgabeFFP1.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/AufgabeFFP1.hs b/AufgabeFFP1.hs index eb9d1fc..8dd52e1 100644 --- a/AufgabeFFP1.hs +++ b/AufgabeFFP1.hs | |||
| @@ -1,5 +1,21 @@ | |||
| 1 | module AufgabeFFP1 | 1 | module AufgabeFFP1 |
| 2 | where | 2 | where |
| 3 | 3 | ||
| 4 | -- calculates 2^ with each element of the continuous list | ||
| 4 | pof2s :: [Integer] | 5 | pof2s :: [Integer] |
| 5 | pof2s = map (2^) [0,1..] | 6 | pof2s = map (2^) [0,1..] |
| 7 | |||
| 8 | -- alternate: | ||
| 9 | -- pof2s :: [Integer] | ||
| 10 | -- pof2s = iterate (2*) 1 | ||
| 11 | |||
| 12 | ------------------------------------------------------------------------------- | ||
| 13 | |||
| 14 | -- iterate steps: | ||
| 15 | -- (1) [1] | ||
| 16 | -- (2) zipWith (+) ([0,1]) ([1,0]) = [1,1] | ||
| 17 | -- (3) zipWith (+) ([0,1,1]) ([1,1,0]) = [1,2,1] | ||
| 18 | -- (4) zipWith (+) ([0,1,2,1]) ([1,2,1,0]) = [1,3,3,1] | ||
| 19 | -- ... | ||
| 20 | pd :: [[Integer]] | ||
| 21 | pd = iterate (\row -> zipWith (+) ([0] ++ row) (row ++ [0])) [1] | ||
