Function fstcan help you here.
Returns the first element of a tuple
Example:
let tuple = (true, 1)
if fst tuple then
//whatever
For the second element also exists snd.
Another alternative is to use pattern matching :
let tuple = (true, 1)
let value =
match tuple with
| (true, _) -> "fst is True"
| (false, _) -> "fst is False"
printfn "%s" value
This allows you to map more complex scenarios, a very powerful construct in F #. Take a look at Tuple's template
source
share