diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-12-11 13:10:37 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-12-11 13:10:37 +0100 |
commit | 248647ecb3d8e7c5343c666ff00d8f0a77c483d2 (patch) | |
tree | 0754773468e5bcc3feca0b8d5fcf951424682bcd /ws2015 | |
parent | d3c5c12d00f82b5b1fe387798f53798790a0ee17 (diff) | |
download | uni-248647ecb3d8e7c5343c666ff00d8f0a77c483d2.tar uni-248647ecb3d8e7c5343c666ff00d8f0a77c483d2.tar.gz uni-248647ecb3d8e7c5343c666ff00d8f0a77c483d2.tar.bz2 uni-248647ecb3d8e7c5343c666ff00d8f0a77c483d2.tar.xz uni-248647ecb3d8e7c5343c666ff00d8f0a77c483d2.zip |
cleanup
Diffstat (limited to 'ws2015')
-rw-r--r-- | ws2015/ffp/blaetter/07/FFP_U07_Monaden2.hs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/ws2015/ffp/blaetter/07/FFP_U07_Monaden2.hs b/ws2015/ffp/blaetter/07/FFP_U07_Monaden2.hs index 8e92dee..7939d36 100644 --- a/ws2015/ffp/blaetter/07/FFP_U07_Monaden2.hs +++ b/ws2015/ffp/blaetter/07/FFP_U07_Monaden2.hs | |||
@@ -282,13 +282,11 @@ memoWinchance atts defs = runST (newSTRef Map.empty >>= memoWinchance' atts defs | |||
282 | memoWinchance' :: forall s. [Monster] -> [Monster] -> STRef s MM -> ST s Double | 282 | memoWinchance' :: forall s. [Monster] -> [Monster] -> STRef s MM -> ST s Double |
283 | memoWinchance' [] _ _ = return 0 -- We do this here so we don't clutter our manual with entries for empty lists | 283 | memoWinchance' [] _ _ = return 0 -- We do this here so we don't clutter our manual with entries for empty lists |
284 | memoWinchance' _ [] _ = return 1 | 284 | memoWinchance' _ [] _ = return 1 |
285 | memoWinchance' atts defs mmRef = recall >>= fromMaybeM (winchance >>= memoize) | 285 | memoWinchance' atts defs mmRef = recall >>= maybe (winchance >>= memoize) return |
286 | where | 286 | where |
287 | recall = Map.lookup (atts, defs) <$> readSTRef mmRef | 287 | recall = Map.lookup (atts, defs) <$> readSTRef mmRef |
288 | memoize x = modifySTRef mmRef (Map.insert (atts, defs) x) >> return x | 288 | memoize x = modifySTRef mmRef (Map.insert (atts, defs) x) >> return x |
289 | winchance = winchance' atts defs mmRef | 289 | winchance = winchance' atts defs mmRef |
290 | fromMaybeM x Nothing = x | ||
291 | fromMaybeM _ (Just x) = return x | ||
292 | 290 | ||
293 | winchance' :: forall s. [Monster] -> [Monster] -> STRef s MM -> ST s Double | 291 | winchance' :: forall s. [Monster] -> [Monster] -> STRef s MM -> ST s Double |
294 | winchance' allatts@(a:atts) alldefs@(d:defs) mmRef | 292 | winchance' allatts@(a:atts) alldefs@(d:defs) mmRef |