Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

Idiom # 53: Join a list of strings

See programming-idioms.org:


fold is the feature of choice to join elements of a set into a value of the element type. For type string, such operations are defined in feature strings. For concatenation with a separator, strings.concat sep is the operation to use.

Mathematically speaking, such an operation is called a monoid. This is why the type of the argument of fold is Monoid, while the operations declared in strings inherit from Monoid.

Since joining the elements of a list into a string using a given separator is a common operation, there is a convenience function to do this directly.

Running Example

Using fold.