diff options
-rw-r--r-- | notes.txt | 22 | ||||
-rw-r--r-- | src/Counter.hs | 7 | ||||
-rw-r--r-- | src/Election.hs | 1 | ||||
-rw-r--r-- | src/Storage.hs | 8 |
4 files changed, 11 insertions, 27 deletions
@@ -1,27 +1,5 @@ -potential anomaly detected for - -Honan, Pat, NT - AEC count 328 - my count 327 - -Marshall, Tristan, NT - AEC count 161 - my count 160 - -Gallagher, Katy, ACT - AEC count 95749 - my count 95748 - -Seselja, Zed, ACT - AEC count 82932 - my count 82931 - -it's probably a programming error on my part - - - future direction ---------------- diff --git a/src/Counter.hs b/src/Counter.hs index 0f3e0d9..bc23671 100644 --- a/src/Counter.hs +++ b/src/Counter.hs @@ -54,12 +54,15 @@ createSenateCounter f a b = do let prefs = parseRawLine a b t0 result = Maybe.fromJust prefs if (Maybe.isJust prefs) - then Vec.setPrefs prefStore n result >> readFunc (n + 1) (p + 1) + then Vec.setPrefs prefStore (p + 1) result >> readFunc (n + 1) (p + 1) else readFunc (n + 1) p p <- readFunc 1 0 IO.hClose h - return (SenateCounter prefStore b p) + return (SenateCounter + { prefData = prefStore + , ballotMap = b + , numBallots = p }) diff --git a/src/Election.hs b/src/Election.hs index 582b29e..ff9706b 100644 --- a/src/Election.hs +++ b/src/Election.hs @@ -300,7 +300,6 @@ doVoteTransfer e = do --- needs to properly mark the order that the last candidates were elected -- needs to be modified to take into account ties checkNoQuota :: Election -> ET.EitherT Election IO Election checkNoQuota e = do 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 |