let ProcessFile (allLines: string list) = let list = new List<List<string>>() let rec SplitFile (input: string list) = if input.Length <> 0 then list.Add(new List<string>(input.TakeWhile(fun x -> x <> ""))) let nextGroup = input.SkipWhile(fun x -> x <> "").SkipWhile(fun x -> x = "") SplitFile (Seq.toList nextGroup) SplitFile allLines |> ignore list
But I was unhappy with this solution. It doesn’t seem idiomatic to new List<List<string>> and store the data in there. So I took to StackOverflow in search of a better answer, which was soon provided: http://stackoverflow.com/questions/11225068/getting-a-list-of-lists-without-using-listliststring-in-f/11225989#11225989
Which directed me to what I wanted, a solution that retained the use of immutable data.