code_junkie

Where can F# actually save time and money?

Nov 10th, 2011
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. [<Measure>] type kg //define a unit of measure
  2. let myMass = 80.0<kg> //define a mass in kg
  3.  
  4. [<Measure>] type m //define a unit of measure
  5. [<Measure>] type s //define a unit of measure
  6. let g = 9.8<m/s^2> //define gravitational acceleration (with units)
  7. let myWeight = myMass * g // result is 784.0<kg m/s ^ 2>
  8.  
  9. //ERROR: The unit of measure 'm' does not match the unit of measure 'kg m/s ^ 2'
  10. let stupidError = myWeight + myMass
Add Comment
Please, Sign In to add comment