Skip to content

Instantly share code, notes, and snippets.

@cannorin
Last active October 2, 2015 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cannorin/8af6ae964f3dea692c44 to your computer and use it in GitHub Desktop.
Save cannorin/8af6ae964f3dea692c44 to your computer and use it in GitHub Desktop.
// 擬似コードです
type CmpResult =
True of Int | False
let > (x : CmpResult, y : CmpResult) : CmpResult =
match (x, y) with
(True m, True n) when Int.> m n -> CmpResult.True m
| (_, _) -> CmpResult.False
let < (x : CmpResult, y : CmpResult) : CmpResult =
match (x, y) with
(True m, True n) when Int.< m n -> CmpResult.True n
| (_, _) -> CmpResult.False
let == (x : CmpResult, y : CmpResult) : CmpResult =
match (x, y) with
(True m, True n) when Int.== m n -> CmpResult.True m
| (_, _) -> CmpResult.False
let != (x : CmpResult, y : CmpResult) : CmpResult =
match (x, y) with
(True m, True n) when Int.!= m n -> CmpResult.True m
| (_, _) -> CmpResult.False
(1 < 2) < 3 // CmpResult.True 3
(2 < 1) < 3 // CmpResult.False
(1 == 1) == 1 // CmpResult.True 1
(1 != 2) != 3 // CmpResult.True 1
(1 == 2) != 3 // CmpResult.False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment