[-Wall *.hs gwern0@gmail.com**20080226030642] { hunk ./Condorcet.hs 9 --- |Candidates are represented as integers. +-- | Candidates are represented as integers. hunk ./Condorcet.hs 29 -loadVotes vs [] = return () +loadVotes _ [] = return () hunk ./Condorcet.hs 35 - loadVoteSet cs rest = - mapM_ loadVote [(a,b) | a <- cs, b <- concat rest] + loadVoteSet ds rst = + mapM_ loadVote [(a,b) | a <- ds, b <- concat rst] hunk ./Condorcet.hs 42 - + hunk ./Condorcet.hs 44 -dim vs = [min..max] where ((min, _), (max, _)) = bounds vs +dim vs = [minim..maxim] where ((minim, _), (maxim, _)) = bounds vs hunk ./Condorcet.hs 52 - mapM_ update [(i,j,k) | i<-range, j<-range, i/=j, k<-range, i/=k, j/=k] where - range = dim vs + mapM_ update [(i,j,k) | i<-ranges, j<-ranges, i/=j, k<-ranges, i/=k, j/=k] where + ranges = dim vs hunk ./Condorcet.hs 76 +-- join :: String -> [String] -> String +-- join sep [] = "" +-- join sep [a] = a +-- join sep (a:b:as) = a ++ sep ++ (join sep (b:as)) hunk ./Condorcet.hs 81 -join :: String -> [String] -> String -join sep [] = "" -join sep [a] = a -join sep (a:b:as) = a ++ sep ++ (join sep (b:as)) - -showVA :: VoteArray -> String -showVA vs = join "\n" (map showRow positions) where - showRow y = join ", " (map (\x -> show $ vs ! (x,y)) positions) - positions = dim vs +-- showVA :: VoteArray -> String +-- showVA vs = join "\n" (map showRow positions) where +-- showRow y = join ", " (map (\x -> show $ vs ! (x,y)) positions) +-- positions = dim vs hunk ./Condorcet.hs 86 -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 +-- 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 hunk ./Condorcet.hs 93 --- |'run' runs the process, taking a list of 'Ballot's and returning a +-- | 'run' runs the process, taking a list of 'Ballot's and returning a hunk ./Demo.hs 11 -{- |Parses a simple form of ballots as strings. -Ballot strings are comma-separated list in order of preference; -equally-ranked candidates are separated with an equals sign. -E.g., "3=4=5,1,2" --} +{- | Parses a simple form of ballots as strings. + Ballot strings are comma-separated list in order of preference; + equally-ranked candidates are separated with an equals sign. + E.g., "3=4=5,1,2" -} }