Created
July 4, 2013 14:27
-
-
Save archaeron/5928233 to your computer and use it in GitHub Desktop.
map over list with options
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 optionize f = | |
function | |
| None -> None | |
| Some(x) -> Some(f x) | |
let newListMap f list = List.map (optionize f) list | |
let listWithNull = [Some 0; Some 6; Some 3; None; Some 34; None; Some 1] | |
let square x = x*x | |
let list1 = List.map (optionize square) listWithNull | |
let list2 = newListMap square listWithNull |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment