summaryrefslogtreecommitdiffstats
path: root/AufgabeFFP4.hs
diff options
context:
space:
mode:
Diffstat (limited to 'AufgabeFFP4.hs')
-rw-r--r--AufgabeFFP4.hs27
1 files changed, 24 insertions, 3 deletions
diff --git a/AufgabeFFP4.hs b/AufgabeFFP4.hs
index 8e7cbf1..1521a5d 100644
--- a/AufgabeFFP4.hs
+++ b/AufgabeFFP4.hs
@@ -2,6 +2,7 @@ module AufgabeFFP4
2where 2where
3 3
4import List 4import List
5import Data.Array
5 6
6type Weight = Int -- Gewicht 7type Weight = Int -- Gewicht
7type Value = Int -- Wert 8type Value = Int -- Wert
@@ -91,7 +92,27 @@ knapsack objects limit = (psol, v)
91 92
92------------------------------------------------------------------------------- 93-------------------------------------------------------------------------------
93 94
94--binomDyn :: (Integer, Integer) -> Integer 95-- see lecture slide #207 ff.
95--binomDyn (m, n) = ... 96newtype Table a b = Tbl (Array b a)
96-- where ... dynamic compB... bndsB... 97 deriving Show
98
99newTable :: (Ix b) => [(b, a)] -> Table a b
100newTable l = Tbl (array (lo, hi) l)
101 where
102 indices = map fst l
103 lo = minimum indices
104 hi = maximum indices
105
106findTable :: (Ix b) => Table a b -> b -> a
107findTable (Tbl a) i = a ! i
108
109updTable :: (Ix b) => (b, a) -> Table a b -> Table a b
110updTable p@(i, x) (Tbl a) = Tbl (a // [p])
111
112dynamic :: (Ix coord) => (Table entry coord -> coord -> entry) -> (coord, coord) -> (Table entry coord)
113dynamic compute bnds = t
114 where
115 t = newTable (map (\coord -> (coord, compute t coord)) (range bnds))
116
117-------------------------------------------------------------------------------
97 118