I have following code that populates a System.Collections.Generic.List I don’t like it so I was wondering if there is a better way to do this.
let getDirectories =
Directory.GetDirectories(_baseFolder)
let languagesList = new System.Collections.Generic.List<string>()
Seq.cast getDirectories
|> Seq.map(fun dir -> (new DirectoryInfo(dir)).Name)
|> fun range -> languagesList.AddRange(range)
Have you tried:
List<'T>has a constructor that takes anIEnumerable<'T>so it happily takes anyseq<'T>you pass to it.