How To Change List of Chars To String?

Viewed 21300

In F# I want to transform a list of chars into a string. Consider the following code:

let lChars = ['a';'b';'c']

If I simply do lChars.ToString, I get "['a';'b';'c']". I'm trying to get "abc". I realize I could probably do a List.reduce to get the effect I'm looking for but it seems like there should be some primitive built into the library to do this.

To give a little context to this, I'm doing some manipulation on individual characters in a string and when I'm done, I want to display the resulting string.

I've tried googling this and no joy that way. Do I need to just bite the bullet and build a List.reduce expression to do this transformation or is there some more elegant way to do this?

7 Answers
    [|'w'; 'i'; 'l'; 'l'|]
    |> Array.map string
    |> Array.reduce (+)

or as someone else posted:

    System.String.Concat([|'w'; 'i'; 'l'; 'l'|])
Related