What is the idiomatic way to take a F# list of string like
let myList = ["BUILD_NUMBER"; "GIT_COMMIT"; "GIT_BRANCH"]
and convert that to a Dictionary where the words above are the keys and the corresponding Environment Variable is the value.
Should all that be done in a one-liner or piped expression? I am missing the FP background to know how to go from list to Dictionary. What is the most idiomatic way to do this in F#?
Environment.GetEnvironmentVariable and the dict function should do the work :
let env =
myList
|> Seq.map (fun var -> var, Environment.GetEnvironmentVariable var)
|> dict
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With