diff options
author | Jed Barber <jjbarber@y7mail.com> | 2017-01-30 15:56:45 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2017-01-30 15:56:45 +1100 |
commit | 4387327f4c2ce91ecefa7fc45c7b5412aad67d07 (patch) | |
tree | f7ae3fb0afced99ca1b8a1bf6d3414336f71b4e7 /src/Storage.hs | |
parent | 64ccf6ef0aa18e898565ff59159dc8165a780f9d (diff) |
Fixed off-by-2 bug with constructing SenateCounter object
Diffstat (limited to 'src/Storage.hs')
-rw-r--r-- | src/Storage.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Storage.hs b/src/Storage.hs index 295273b..be9b8af 100644 --- a/src/Storage.hs +++ b/src/Storage.hs @@ -28,7 +28,9 @@ data Store = Store createStore :: Int -> Int -> IO Store createStore maxCapacity ballotSize = do v <- Vec.replicate (maxCapacity * ballotSize) 0 - return (Store v ballotSize) + return (Store + { getPointer = v + , getBallotSize = ballotSize }) @@ -42,7 +44,9 @@ setPref prefStore ballot (position,rank) = do setPrefs :: Store -> Int -> [Preference] -> IO () -setPrefs prefStore ballot prefList = +setPrefs prefStore ballot prefList = do + let blank = take (getBallotSize prefStore) (zip [1..] (cycle [0])) + mapM_ (setPref prefStore ballot) blank mapM_ (setPref prefStore ballot) prefList |