On Wed, 18 Mar 2009, Eric Kow wrote:
Also, I'll attach a crude calculator that I'll be using to compute the
reimbursements (warning, it may have bugs), the core of which can be
described by the following Haskell function:
reimbursements pot [] = []
reimbursements pot (x:xs) = payment : reimbursements leftover xs
where
payment = min share x
leftover = pot - payment
share = pot / fromIntegral l
l = 1 + length xs
I think this is indeed buggy, or at least underspecified, btw: suppose one
person needs $990 and the other needs $10, then if the list is [10,990]
they'll both get what they need, but if it's [990, 10] then the first
person will only get $500. However if we require the input list to be
sorted first, I think it's ok.
Ganesh
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users