Repeat a string: Difference between revisions
Content added Content deleted
(added sml) |
|||
Line 565:
end
</lang>
=={{header|Standard ML}}==
<lang sml>fun string_repeat (s, n) =
concat (List.tabulate (n, fn _ => s))
;</lang>
testing in the interpreter:
<lang sml>- string_repeat ("Hiuoa", 3) ;
val it = "HiuoaHiuoaHiuoa" : string</lang>
To repeat a single character:
<lang sml>fun char_repeat (c, n) =
implode (List.tabulate (n, fn _ => c))
;</lang>
=={{header|Suneido}}==
|