Repeat a string: Difference between revisions

Line 748:
 
=={{header|Euphoria}}==
A simple loop will do:
<lang Euphoria>
sequence x = ""
for i = 1 to 5 do x &= "ha" end for
puts(1,x)
</lang>
 
But wait, here's another way:
<lang Euphoria>
include std/console.e -- for display
Line 753 ⟶ 761:
object x = flatten(repeat("ha",5))
display(x)
</lang>
/* note: repeat creates a sequence of ha's as shown below; flatten concatenates them.
 
/* note: repeat creates a sequence of ha's as shown below; flatten concatenates them.
<lang Euphoria>
{
"ha",
Line 761 ⟶ 772:
"ha"
}
*/
</lang>
 
Anonymous user