I'm very new to F# so I have been trying to sum all the elements(double integers) line in a text file to print out year and the total number of elements.
(sample from text file):
2010 **(the elements)->** 1.07 1.56 1.74 3.84 6.8 7.89 9.2 3.46 1.67 2.22 2.49 2.81
However, here is my recursion function to sum all the elements. I get the big error in the main with the explanation in the codes below.
let rec sum values:double list =
if values = [] then
[]
else
values.Head + sum values.Tail
let main argv =
// read entire file as list of strings:
let file = ReadFile "rainfall-midway.txt"
let (year, values) = ParseLine file.Head
printfn "%A: %A" year (sum [values]) // values gets the error which i cannot understand at all.
Error 1 The type
'float list'
does not support the operator'+'