Last active
August 29, 2015 14:05
-
-
Save yukitos/f1b16c8b96824e59c2aa to your computer and use it in GitHub Desktop.
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
let values = [ 1;2;3;2;3;1 ] | |
let f y x = | |
if x = y then Choice2Of2 1 | |
else if x < y then Choice1Of2 2 | |
else Choice2Of2 3 | |
let ``all values are Choice1Of2`` = | |
values | |
|> List.map (f 4) | |
let sequence1 = | |
``all values are Choice1Of2`` | |
|> FSharpx.Choice.sequence | |
let ``contains Choice2Of2`` = | |
values | |
|> List.map (f 2) | |
let sequence2 = | |
``contains Choice2Of2`` | |
|> FSharpx.Choice.sequence |
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
val values : int list = [1; 2; 3; 2; 3; 1] | |
val f : y:'a -> x:'a -> Choice<int,int> when 'a : comparison | |
val ( all values are Choice1Of2 ) : Choice<int,int> list = | |
[Choice1Of2 2; Choice1Of2 2; Choice1Of2 2; Choice1Of2 2; Choice1Of2 2; | |
Choice1Of2 2] | |
val sequence1 : Choice<int list,int> = Choice1Of2 [2; 2; 2; 2; 2; 2] | |
val ( contains Choice2Of2 ) : Choice<int,int> list = | |
[Choice1Of2 2; Choice2Of2 1; Choice2Of2 3; Choice2Of2 1; Choice2Of2 3; | |
Choice1Of2 2] | |
val sequence2 : Choice<int list,int> = Choice2Of2 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment