Quantcast
Channel: User Tarmil - Stack Overflow
Viewing all articles
Browse latest Browse all 39

Answer by Tarmil for F# unit of measure to model area

$
0
0

There are several things here:

  1. You need to define area as being a square length with type area = radius * radius. Otherwise the compiler has no way to match your input and output units.

  2. Pi, when used like this, is dimensionless, which is represented in F# as <1> or just no unit suffix.

[<Measure>] type radius[<Measure>] type area = radius * radiuslet convertRadiusToArea (r:float<radius>) : float<area>  =    let pi = System.Math.PI    r * r * pi

Viewing all articles
Browse latest Browse all 39

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>