4 ms·
Your F# example can be more concise: type Shape = | Circle of float | Square of float let area = function | Circle r -> Math.
by louthy 12y ago
Your F# example can be more concise:
type Shape =
| Circle of float
| Square of float
let area = function
| Circle r -> Math.PI * r * r
| Square sd -> sd * sd
let perimeter = function
| Circle r -> 2.0 * Math.PI * r
| Square sd -> sd * 4.0
- noblethrasher 12y agoWell, that's just... neat.