Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
8
Task/Monads-Maybe-monad/F-Sharp/monads-maybe-monad.fs
Normal file
8
Task/Monads-Maybe-monad/F-Sharp/monads-maybe-monad.fs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// We can use Some as return, Option.bind and the pipeline operator in order to have a very concise code
|
||||
|
||||
|
||||
let f1 (v:int) = Some v // int -> Option<int>
|
||||
let f2 (v:int) = Some(string v) // int -> Option<sting>
|
||||
|
||||
f1 4 |> Option.bind f2 |> printfn "Value is %A" // bind when option (maybe) has data
|
||||
None |> Option.bind f2 |> printfn "Value is %A" // bind when option (maybe) does not have data
|
||||
Loading…
Add table
Add a link
Reference in a new issue