Created
July 17, 2011 04:28
-
-
Save smly/1087181 to your computer and use it in GitHub Desktop.
ternary operator like expression
This file contains hidden or 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
| datatype 'a ternarylikeop = TrueExpression of 'a | FalseExpression | |
| fun op ? (true, y) = TrueExpression y | |
| | op ? (_, y) = FalseExpression | |
| infix 6 ?; | |
| fun op :- (TrueExpression x, _) = x | |
| | op :- (FalseExpression, y) = y | |
| infix 6 :-; | |
| val test01 = (35 < 3) ? 2 :- 1; | |
| val test02 = (35 > 3) ? 2 :- 1; | |
| (* | |
| - [opening /Users/smly/gitws/practice/smlnj/ternary_operation.sml] | |
| datatype 'a ternarylikeop = FalseExpression | TrueExpression of 'a | |
| val ? = fn : bool * 'a -> 'a ternarylikeop | |
| infix 6 ? | |
| val :- = fn : 'a ternarylikeop * 'a -> 'a | |
| infix 6 :- | |
| val test01 = 1 : int | |
| val test02 = 2 : int | |
| *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment