Last active
December 11, 2020 14:20
-
-
Save rcurtis/a571146131f5d09ddaf5c1d5f2bbedc8 to your computer and use it in GitHub Desktop.
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
let rec containsAllKeysRec (keys: string list)(map: Map<string, string>) : bool = | |
let rec found k (m: Map<_,_>) = | |
match k with | |
| [x] -> if m.ContainsKey x then true else false | |
| x::xs -> found xs m | |
| _ -> true | |
found keys map | |
let containsAllKeys (keys: string list)(map: Map<string, string>) : bool = | |
let mutable missing = false | |
for key in keys do | |
if map.ContainsKey key |> not then do | |
missing <- true | |
missing |> not | |
let containsAllKeysBuiltIn (keys: string list)(map: Map<string, string>) : bool = | |
keys | |
|> List.exists (fun key -> map.ContainsKey key |> not) | |
|> not |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment