fslaborg / flips

Fsharp LInear Programming System
https://flipslibrary.com/#/
MIT License
252 stars 32 forks source link

SMap addition was wrong: #96

Closed smoothdeveloper closed 3 years ago

smoothdeveloper commented 3 years ago
let a = SMap.ofList [for i in 3..5 -> i,i]
let b = SMap.ofList [for i in 3..5 -> i,i]
let c = a + b
// SMap map [(3, 9); (4, 16); (5, 25)]

usage of units of measure would highlight it:

let a = SMap.ofList [for i in 3..5 -> i,float i * 1.<Item>]
let b = SMap.ofList [for i in 3..5 -> i,float i * 1.<Item>]
let c = a + b // error FS0001: The unit of measure 'Item' does not match the unit of measure 'Item ^ 2'

add one test over SMap + one that checks the result of pairwise addition keeps unit of measure unchanged on the lhs