Anonymous user
Repeat a string: Difference between revisions
→{{header|Mathematica}}
Line 559:
=={{header|Mathematica}}==
<lang Mathematica>(* solution 1 *)
rep[n_Integer,s_String]:=Apply[StringJoin,ConstantArray[
(* solution 2 -- @@ is the infix form of Apply[] *)
rep[n_Integer,s_String]:=StringJoin @@ Table[
(* solution 3 -- demonstrating another of the large number of looping constructs available *)
rep[n_Integer,s_String]:=Nest[StringJoin[
</lang>
|