This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<Measure>] type Length | |
[<Measure>] type Area = Length*Length | |
let area (b : float<Length>) (a: float<Length>) = a*b^2 | |
let a1:float<Area> = area 3.0<Length> 5.0<Length> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<Measure>] type Length | |
[<Measure>] type Area = Length*Length | |
let area (a : float<Length>) (b: float<Length>) = a * a + b * b | |
let a1:float<Area> = area 0.0<Length> 1.0<Length> | |
a1.Dump() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<Measure>] type Length | |
[<Measure>] type Area = Length*Length | |
let area (a : float<Length>) (b: float<Length>) = a * a *a / b | |
let a1:float<Area> = area 0.0<Length> 1.0<Length> | |
let a2:float<Area> = area 1.0<Length> 0.0<Length> | |
("for 0,1: " + a1.ToString()).Dump() | |
("for 1,0: " + a2.ToString()).Dump() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<Measure>] type Length | |
[<Measure>] type Area = Length*Length | |
let area (a : float<Length>) (b: float<Length>) = 2.0*a*b | |
let a1:float<Area> = area 0.0<Length> 1.0<Length> | |
let a2:float<Area> = area 1.0<Length> 0.0<Length> | |
let a3:float<Area> = area 1.0<Length> 1.0<Length> | |
("for 0,1: " + a1.ToString()).Dump() | |
("for 1,0: " + a2.ToString()).Dump() | |
("for 1,1, circle should be pi: " + a3.ToString()).Dump() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<Measure>] type Length | |
[<Measure>] type Area = Length*Length | |
let area (a : float<Length>) (b: float<Length>) = System.Math.PI*a*b | |
let a1:float<Area> = area 0.0<Length> 1.0<Length> | |
let a2:float<Area> = area 1.0<Length> 0.0<Length> | |
let a3:float<Area> = area 1.0<Length> 1.0<Length> | |
("for 0,1: " + a1.ToString()).Dump() | |
("for 1,0: " + a2.ToString()).Dump() | |
("for 1,1, circle should be pi: " + a3.ToString()).Dump() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<Measure>] type m | |
[<Measure>] type s | |
[<Measure>] type kg | |
[<Measure>] type N = kg m / s / s | |
let a = 9.81<m/s/s> | |
let mass = 10.0<kg> | |
let f = a*mass | |
let pow3 (x:float<'u>):float<'u^3> = | |
let power = pown (float x) 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.IO | |
open FsCheck | |
open FsCheck.Xunit | |
[<Measure>] type m | |
[<Measure>] type Area = m^2 | |
[<Measure>] type Volume = Area*m | |
let f (h:decimal<m>) = h |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let VolumeNoHeightis0(a:decimal<m>) = | |
(a <= 10000000000m<m> && a >= 0m<m>) ==> | |
(lazy (V 0m<m> a a = 0m<m^3>)) | |
Check.Quick VolumeNoHeightis0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let RoundM3 (cubic:decimal<m^3>): decimal<m^3> = Math.Round(cubic * 1m<m^-3>,10)*1m<m^3> | |
let VolumeAIsBEqualssquare((a:decimal<m>), (h:decimal<m>)) = | |
RoundM3 (V h a a) = RoundM3( a * a * h ) | |
let twoDecimals = Arb.generate<decimal<m>> |> Gen.suchThat ((<) 0m<m>) |> Gen.suchThat ((>) 1000000m<m>) |> Gen.two |> Arb.fromGen | |
Check.Quick (Prop.forAll twoDecimals VolumeAIsBEqualssquare) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let g (a: decimal<m>) (b: decimal<m>):decimal<m^2> = (a*a + b*b) / 2m |