I have a list of lines that that have hard breaks at a specific line number, and look like this:
Header:<SmallJson>
Header:<VeryLongJson...
....>
Header:<Json>
And I need to process it so it removes the line breaks, so it becomes like this:
Header:<SmallJson>
Header:<VeryLongJson.......>
Header:<Json>
I've come up with a solution but I'm not particularly happy about it:
let rawLines = [ "Header:<SmallJson>"
                 "Header:<VeryLongJson..."
                 "....>"
                 "Header:<Json>" ]
let processedLines = 
    (([], ""), rawLines)
    ||> List.fold (fun (result, state) line -> 
        if line.StartsWith "Header:"
        then state::result, line
        else result, state + line)
    |> (fun (result, state) -> state::result)
    |> List.rev
    |> List.tail
Is there a way to make this in a simpler way? The extra state::result and List.tail at the end of the fold particularly annoy me. Preferably without using mutation