Skip to content

Instantly share code, notes, and snippets.

@rcurtis
Last active December 11, 2020 14:20
Show Gist options
  • Save rcurtis/a571146131f5d09ddaf5c1d5f2bbedc8 to your computer and use it in GitHub Desktop.
Save rcurtis/a571146131f5d09ddaf5c1d5f2bbedc8 to your computer and use it in GitHub Desktop.
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