F# string building

I want to do this C# code in F#

  string[] a = new string[5];
    string b = string.Empty;
    a[0] = "Line 1";
    a[2] = "Line 2";

    foreach (string c in a)
        b = c + Environment.NewLine;


Its a lot better to use the built-in String.Join method than rolling your own function based on repeated string concatting. Here's the code in F#:

open System
let a = [| "Line 1"; null; "Line 2"; null; null;|] 
let b = String.Join(Environment.NewLine, a)

Need Your Help

How to prevent EditText from breaking a line after punctuation

android text line android-edittext punctuation

As default, an Android EditText will break a line if the line is longer than the view, like this:

How does Java web-app with @SessionScoped Bean know if browser is re-started?

java jsf web-applications

This is a pretty basic question. I'm learning from a textbook about JSF web apps, and using a @SessionScoped Bean to manage the session. The book mentioned that if you close the browser, the sess...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.