Skip to content

Instantly share code, notes, and snippets.

@djellemah
Created September 20, 2022 17:15
Show Gist options
  • Save djellemah/320b8c90d700fc37d509d4b03673c8c7 to your computer and use it in GitHub Desktop.
Save djellemah/320b8c90d700fc37d509d4b03673c8c7 to your computer and use it in GitHub Desktop.
get environment variables in F#
let dict_map (dict : System.Collections.IDictionary) =
let values = ref (Map<'a,'b> [])
for obj in dict do
let de = obj :?> System.Collections.DictionaryEntry
values := Map.add (de.Key :?> 'a) (de.Value :?> 'b) !values
!values
System.Environment.GetEnvironmentVariables() |> dict_map<string,string>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment