Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mkTotals :: [[(Key,Int)]] -> ST s [(Key,Int)]
- mkTotals prices = do
- totals <- newArray bounds 0 :: ST s (STArray s Key Int)
- forM_ prices
- (\price -> do
- checks <- newArray bounds False :: ST s (STArray s Key Bool)
- forM_ price
- (\(k,v) -> do
- check <- readArray checks k
- if check then
- return ()
- else do
- writeArray checks k True
- cv <- readArray totals k
- writeArray totals k (cv + v)))
- getAssocs totals
- where
- bounds = ((-9,-9,-9,-9), (9,9,9,9))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement