Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I concatenate a list of strings in F#?

Tags:

f#

I'm trying this at the moment, but I haven't quite got the method signature worked out... anyone? messages is a field of seq[string]

let messageString = List.reduce(messages, fun (m1, m2) -> m1 + m2 + Environment.NewLine) 
like image 984
mwjackson Avatar asked Nov 22 '09 15:11

mwjackson


People also ask

How do I concatenate a list of strings?

You can concatenate a list of strings into a single string with the string method, join() . Call the join() method from 'String to insert' and pass [List of strings] . If you use an empty string '' , [List of strings] is simply concatenated, and if you use a comma , , it makes a comma-delimited string.

How do you concatenate list items?

The most conventional method to perform the list concatenation, the use of “+” operator can easily add the whole of one list behind the other list and hence perform the concatenation.

How do you concatenate all elements in a list in Python?

To concatenate a list of integers an empty list is created as newlist = []. The extend method() adds all the elements of the list till the end. To concatenate the list on integers “+” is used. The print(newlist) is used to get the output.


1 Answers

> String.concat " " ["Juliet"; "is"; "awesome!"];; val it : string = "Juliet is awesome!" 
like image 106
Juliet Avatar answered Nov 11 '22 18:11

Juliet