Safe Haskell | Safe-Inferred |
---|---|

Language | Haskell2010 |

- largestRemainder :: RealFrac a => [a] -> [Int]
- largestRemainderScaled :: RealFrac a => Int -> [a] -> [Int]
- highestAveragesScaled :: RealFrac a => [a] -> Int -> [a] -> [Int]
- dHondtDivisors :: Num a => [a]
- sainteLagueDivisors :: Num a => [a]

# Documentation

largestRemainder :: RealFrac a => [a] -> [Int] Source

This function rounds values such that the sum of the rounded values matches the rounded sum of the original values.

Also known as Hare-Niemeyer method. https://en.wikipedia.org/wiki/Largest_remainder_method

Input values must be non-negative, otherwise `properFraction`

bites us.

largestRemainderScaled :: RealFrac a => Int -> [a] -> [Int] Source

`largestRemainderScaled s xs`

scales and rounds the values in `xs`

such that their sum becomes `s`

.

E.g. `largestRemainderScaled 100 [1,2,3]`

returns integral percentages proportional to 1:2:3.

highestAveragesScaled :: RealFrac a => [a] -> Int -> [a] -> [Int] Source

https://en.wikipedia.org/wiki/Highest_averages_method

In `highestAveragesScaled divs s xs`

,
`divs`

must be an infinite list of strictly increasing positive numbers.
E.g. `highestAveragesScaled dHondtDivisors s xs`

runs the d'Hondt method.

dHondtDivisors :: Num a => [a] Source

sainteLagueDivisors :: Num a => [a] Source