Created
February 26, 2015 00:06
-
-
Save anonymous/d8e0e151c35f8784f895 to your computer and use it in GitHub Desktop.
This file contains 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
type Primitive with | |
member x.Length = | |
let rec calcLength = | |
function | |
| Circle (_,r) -> System.Math.PI * r * 2. | |
| Ellipse (_,r1,r2) -> System.Math.PI * 2. * sqrt( (r1 * r1 ) + (r2 * r2 ) / 2. ) | |
| Square (_, w,_) -> w * 4. | |
| MultiPrimitive xs -> List.fold (fun c x -> c + calcLength x) 0. xs | |
calcLength x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment