Created
October 7, 2012 06:17
-
-
Save abcsharp/3847287 to your computer and use it in GitHub Desktop.
CustomOperationでくだらない事をしてみた
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 Calc() = | |
[<CustomOperation("clear")>] | |
member it.Clear _ = 0 | |
[<CustomOperation("invert")>] | |
member it.Invert a = -a | |
[<CustomOperation("assign")>] | |
member it.Assign (_, a) = a | |
[<CustomOperation("add")>] | |
member it.Add (a, b) = a + b | |
[<CustomOperation("sub")>] | |
member it.Sub (a, b) = a - b | |
[<CustomOperation("mul")>] | |
member it.Mul (a, b) = a * b | |
[<CustomOperation("div")>] | |
member it.Div (a, b) = a / b | |
[<CustomOperation("mod")>] | |
member it.Mod (a, b) = a % b | |
[<CustomOperation("sqrt")>] | |
member it.Sqrt a = (float >> sqrt >> int) a | |
[<CustomOperation("print")>] | |
member it.Print a = printf "%i" a | |
member it.Yield a = a | |
let calc = new Calc() | |
calc{ | |
assign 1 | |
add 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment