[cleanups Evan Martin **20060313115708] { hunk ./Condorcet.hs 24 -type STVoteArray s = STUArray s (Int,Int) Int +-- Entry (i,j) having value k means that i beats j in k votes. hunk ./Condorcet.hs 26 +type STVoteArray s = STUArray s (Int,Int) Int hunk ./Condorcet.hs 46 -initPaths :: VoteArray -> (STVoteArray s) -> ST s () +initPaths :: VoteArray -> STVoteArray s -> ST s () hunk ./Condorcet.hs 50 -floyd :: VoteArray -> (STVoteArray s) -> ST s () +floyd :: VoteArray -> STVoteArray s -> ST s () hunk ./Condorcet.hs 72 - isWinner c = all (c `beats`) candidates + isWinner c = (c `beats`) `all` candidates hunk ./Condorcet.hs 87 +loadBallots :: [Ballot] -> ST s (STVoteArray s) +loadBallots ballots = do + let size = maximum $ concat $ concat ballots + votes <- newArray ((1,1),(size,size)) 0 + mapM_ (loadVotes votes) ballots + return votes + }