Skip to content

Latest commit

 

History

History
17 lines (14 loc) · 378 Bytes

misc.md

File metadata and controls

17 lines (14 loc) · 378 Bytes

Good examples

What'd be nice to decide automatically?

Value : Type
Value = { ν : Int | ν >= 0 & ν <= 100 }

Weight : Type
Weight = { ν : Int | ν > 0 }

weightedAvg : [(Weight, Value)] -> Value
weightedAvg [] = 0
weightedAvg wvals = sumVals `div` totalWeight
  where
    sumVals = sum $ fmap (\(w, x) -> w * x) wvals
    totalWeight = sum $ fmap fst wvals