tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
8
Task/Repeat-a-string/Mathematica/repeat-a-string.math
Normal file
8
Task/Repeat-a-string/Mathematica/repeat-a-string.math
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(* solution 1 *)
|
||||
rep[n_Integer,s_String]:=Apply[StringJoin,ConstantArray[s,{n}]]
|
||||
|
||||
(* solution 2 -- @@ is the infix form of Apply[] *)
|
||||
rep[n_Integer,s_String]:=StringJoin@@Table[s,{n}]
|
||||
|
||||
(* solution 3 -- demonstrating another of the large number of looping constructs available *)
|
||||
rep[n_Integer,s_String]:=Nest[StringJoin[s, #] &,s,n-1]
|
||||
Loading…
Add table
Add a link
Reference in a new issue