F# parse data and calculate sum
You should reduce the use of explicit type declaration as much as possible.



A function isn't of much value if it just prints its calculated result. You should return the result to let it be up to the client to handle it.

But you can't break out from a loop via an if-statement in F#. You can overcome that by wrapping the outer for-loop in a seq {...} statement and then yield the one and only result and then take the first element from that sequence. But that is inefficient in that it iterates through all the cities even if the first is the one searched for.

Below I've refactored your algorithm according to the above in order to be able to return the result from the function:

let SumByTown town input =
    let rows = (string input).Split('\n')
    seq { for row in rows do
            if (row.Contains(town)) then 
                let months = row.Replace(town + ":" , "").Split(',')
                let sequence = seq { for j in months do yield j.Remove(0,4) |&gt; double } |&gt; Seq.sum
                yield sequence
    } |&gt; Seq.head


But this still doesn't look very functional IMO.



For inspiration is here a version that uses the built in higher order functions in a more functional manner:

let calculateCity city data =
    let sum values = values |&gt; Array.sum
    let avg values = values |&gt; Array.average
    let mean values = (values |&gt; Array.sort).[values.Length / 2]

    let handleCity cityText = 
        let values = Regex.Replace(cityText, "[^0-9,.]+", "").Split(',') |&gt; Array.map float
        (sum values, avg values, mean values)

    (string data).Split('\n') |&gt; Seq.find (fun s -&gt; s.StartsWith(city)) |&gt; handleCity

let printCityData (sum, avg, mean) = printfn "Sum: %.2f, Average: %.2f, Mean: %.2f" sum avg mean


Usage:

printCityData (calculateCity town data)




Update

Antoher way to use Regex is to match numbers instead of removing non-numeric chars:

let calculateCity1 city data =
    let sum values = values |&gt; Seq.sum
    let avg values = values |&gt; Seq.average
    let mean values = (values |&gt; Seq.sort).ElementAt((values|&gt; Seq.length)/ 2)
    let extractValues text = Regex.Matches(text, "\d+.\d+").Cast&lt;Match&gt;() |&gt; Seq.map (fun m -&gt; m.Value)

    let handleCity cityText = 
        let values = cityText |&gt; extractValues |&gt; Seq.map float
        (sum values, avg values, mean values)

    (string data).Split('\n') |&gt; Seq.find (fun s -&gt; s.StartsWith(city)) |&gt; handleCity

let printCityData (sum, avg, mean) = printfn "Sum: %.2f, Average: %.2f, Mean: %.2f" sum avg mean


This requires an open System.Linq at the top of the module