String concatenation: Difference between revisions

Corrected according to the requirements
(Added Ela)
(Corrected according to the requirements)
Line 369:
=={{header|Ela}}==
Strings in Ela support a polymorphic concatenation operator (++):
<lang ela>"Hello"hello ++= "," ++ "worldHello"</lang>
hello'world = hello ++ ", " ++ "world"
(hello, hello'world)</lang>
{{out}}
<pre>("Hello", "Hello, world!")</pre>
However, as long as strings in Ela are indexed arrays, this operator is not very effective for
a large number of concatenations. Therefore one can use an alternate technique (a pure StringBuilder
type defined in standard prelude). The resulting code would look like so:
<lang ela>toString $ "Hello" +> ", " +> "world"</lang>
The (+>) token is a type constructor. Therefore the result of its application is an instance of type
StringBuilder. In order to produce a string one should call a polymorphic toString function at the end
Anonymous user