https://dotnetfiddle.net/8rtpmV
type Currency = Currency of decimal
type Tree =
| Branch of T * Tree * Tree
| Leaf of T
[Serializable]
public class Currency :
IEquatable<Currency>,
IStructuralEquatable,
IComparable<Currency>,
IComparable,
IStructuralComparable
{
public decimal Value { get; private set; }
public void Currency(decimal value) { this.Value = value; }
..about 300 lines of interface implementation..
}
let rec fib n =
match n with
| 0 -> 0
| 1 -> 1
| _ -> fib(n-1) + fib(n-2)
static int Fib(int x)
{
switch (x) {
case 0: return 0;
case 1: return 1;
default: return Fib(x - 1) + Fib(x - 2);
}
}
let (|Regex|_|) pattern input =
let m = Regex.Match(input, pattern)
if m.Success then Some(List.tail [ for g in m.Groups -> g.Value ])
else None
let parsed = match input with
| Regex @"^\$([\d]+\.[\d]{2})$" [value] -> Convert.ToDecimal(value)
| Regex @"^([\d]+\.[\d]{2})$" [value] -> Convert.ToDecimal(value)
| Regex @"^(\.[\d]{2})$" [value] -> Convert.ToDecimal(value)
| _ -> raise(InputError "Invalid input, please try again.")