From: davo on
In some languages "S" * n returns a string of n "S"s...

is there a built in to do this in Mathematica - I can't find it in the
docs..

Again, thanks

Chris

From: Bill Rowe on
On 3/14/10 at 5:12 AM, the.wright.email(a)gmail.com (davo) wrote:

>In some languages "S" * n returns a string of n "S"s...

>is there a built in to do this in Mathematica - I can't find it in
>the docs..

There is no built in function to do this as far as I know. But
it is a simple matter to create one. For example

In[6]:= strTimes[x_String, n_Integer] := Nest[# <> x &, "", n]

In[7]:= strTimes["S", 6]

Out[7]= SSSSSS

In[8]:= StringLength[%]

Out[8]= 6


From: Leonid Shifrin on
Hi Chris,

In some languages "S" * n returns a string of n "S"s...
>
> is there a built in to do this in Mathematica - I can't find it in the
> docs..
>

To my knowledge, there isn't. But it is trivial to implement:

Clear[stringRepeat];
stringRepeat[s_String, n_Integer?Positive] :=
StringJoin @@ Table[s, {n}]

In[1]:=
stringRepeat["S", 10]

Out[1]= "SSSSSSSSSS"


Regards,
Leonid



>
> Again, thanks
>
> Chris
>
>


From: dh on


function to the use simplier. E.g a "a" followed by 10 "b"'s:

On 14.03.2010 11:11, davo wrote:

E-Mail:<mailto:dh(a)metrohm.com>

Internet:<http://www.metrohm.com>



 | 
Pages: 1
Prev: visible and invisible button
Next: applescript