Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have String.ofChars in the standard library #475

Open
cloudRoutine opened this issue Oct 12, 2016 · 0 comments
Open

Have String.ofChars in the standard library #475

cloudRoutine opened this issue Oct 12, 2016 · 0 comments

Comments

@cloudRoutine
Copy link
Owner

Idea 9324276: Have String.ofChars in the standard library

Status : open
Submitted by Bang Jun-young on 8/14/2015 12:00:00 AM
10 votes

Wouldn't it be convenient if String.ofChars function was part of the standard library? The implementation is quite straightforward:
module String =
let ofSeq (seq: char seq) =
seq |> (System.Text.StringBuilder() |> Seq.fold (fun sb c -> sb.Append(c))) |> string
Currently, we have to use an inefficient chaining to convert a seq of characters to a string:
['a'; 'b'; 'c'] |> Array.ofList |> System.String
which can be simplified with String.ofChars:
['a'; 'b'; 'c'] |> String.ofChars
String.ofSeq also can be handy for profiles like PCL where the String type is not regarded as seq.

Archived Uservoice Comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant