In F#"Hello"+"World" gives "HelloWorld". I mean the + operator can concatenate the strings.
Given this code:
let iprint list:List<int> =
let stringList=int2String4List list //convert the int list to string list
List.foldBack (fun acc elem -> acc+elem+',' ) stringList ""
but i faced with the error:
The type 'List<int>' does not match the type 'string'
It seems to me the F# interpreted the datatype of stringList as int meanwhile it is a List<string>. but i do not know how does it happen?
List.foldBack : ('T -> 'State -> 'State) -> 'T list -> 'State -> 'State
This means, the datatype of first parameter of function and the list must be the same, but why it is insisting to accept + as an int operator, but not a string operator?
int2String4Listfunction? - Petrlet iprint (list:List<int>) =- Petr