summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-23 19:02:47 +0100
committermanuel <manuel@mausz.at>2012-03-23 19:02:47 +0100
commitc9e70808546f2a6b58e1729d64e7ae8bbc17a98e (patch)
tree973beee0921caea1bd60126cf8d1ee2f5759f593
parent6d7f692ac38f9e2964aed76574c989990f1e573b (diff)
downloadffp-c9e70808546f2a6b58e1729d64e7ae8bbc17a98e.tar.gz
ffp-c9e70808546f2a6b58e1729d64e7ae8bbc17a98e.tar.bz2
ffp-c9e70808546f2a6b58e1729d64e7ae8bbc17a98e.zip
implement fibdiags (+ some indention stuff)
-rw-r--r--AufgabeFFP1.hs5
-rw-r--r--TestAufgabeFFP1.hs24
2 files changed, 23 insertions, 6 deletions
diff --git a/AufgabeFFP1.hs b/AufgabeFFP1.hs
index 88d46b4..b393fc2 100644
--- a/AufgabeFFP1.hs
+++ b/AufgabeFFP1.hs
@@ -38,3 +38,8 @@ fibdiag (n)
38 | otherwise = map (\x -> pd !! (fromInteger n - x) !! (x - 1)) [1..count] 38 | otherwise = map (\x -> pd !! (fromInteger n - x) !! (x - 1)) [1..count]
39 where 39 where
40 count = (fromInteger n + 1) `div` 2 40 count = (fromInteger n + 1) `div` 2
41
42-------------------------------------------------------------------------------
43
44fibdiags :: [[Integer]]
45fibdiags = map (fibdiag) [1,2..]
diff --git a/TestAufgabeFFP1.hs b/TestAufgabeFFP1.hs
index 7cbc2c2..1fa5c35 100644
--- a/TestAufgabeFFP1.hs
+++ b/TestAufgabeFFP1.hs
@@ -10,17 +10,20 @@ assertBoolF msg b = when b (assertFailure msg)
10------------------------------------------------------------------------------- 10-------------------------------------------------------------------------------
11 11
12pof2s1 :: Test 12pof2s1 :: Test
13pof2s1 = TestCase (assertEqual "pof2s" [1,2,4,8,16,32,64,128,256,512] (take 10 pof2s)) 13pof2s1 = TestCase (assertEqual "pof2s"
14 [1,2,4,8,16,32,64,128,256,512]
15 (take 10 pof2s))
14 16
15pof2sTests = TestList [pof2s1] 17pof2sTests = TestList [pof2s1]
16 18
17------------------------------------------------------------------------------- 19-------------------------------------------------------------------------------
18 20
19pd1 :: Test 21pd1 :: Test
20pd1 = TestCase (assertEqual "pd" [[1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1], 22pd1 = TestCase (assertEqual "pd"
21 [1,5,10,10,5,1], [1,6,15,20,15,6,1], [1,7,21,35,35,21,7,1], 23 [[1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1], [1,5,10,10,5,1],
22 [1,8,28,56,70,56,28,8,1], [1,9,36,84,126,126,84,36,9,1], 24 [1,6,15,20,15,6,1], [1,7,21,35,35,21,7,1], [1,8,28,56,70,56,28,8,1],
23 [1,10,45,120,210,252,210,120,45,10,1]] (take 11 pd)) 25 [1,9,36,84,126,126,84,36,9,1], [1,10,45,120,210,252,210,120,45,10,1]]
26 (take 11 pd))
24 27
25pdTests = TestList [pd1] 28pdTests = TestList [pd1]
26 29
@@ -55,8 +58,17 @@ fibdiagTests = TestList [fibdiag1, fibdiag2, fibdiag3, fibdiag4, fibdiag5,
55 58
56------------------------------------------------------------------------------- 59-------------------------------------------------------------------------------
57 60
61fibdiags1 :: Test
62fibdiags1 = TestCase (assertEqual "fibdiags"
63 [[1], [1], [1,1], [1,2], [1,3,1], [1,4,3], [1,5,6,1], [1,6,10,4]]
64 (take 8 fibdiags))
65
66fibdiagsTests = TestList [fibdiags1]
67
68-------------------------------------------------------------------------------
69
58tests :: [Test] 70tests :: [Test]
59tests = [pof2s1, pdTests, fibdiagTests] 71tests = [pof2s1, pdTests, fibdiagTests, fibdiagsTests]
60 72
61main = do 73main = do
62 forM tests $ \test -> 74 forM tests $ \test ->