Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,3 @@
repeat(s,n)={
if(n, Str(repeat(s, n-1), s), "")
};

View file

@ -0,0 +1 @@
repeat(s,n)=concat(vector(n,i, s));

View file

@ -0,0 +1,8 @@
repeat(s,n)={
if(n<4, return(concat(vector(n,i, s))));
if(n%2,
Str(repeat(Str(s,s),n\2),s)
,
repeat(Str(s,s),n\2)
);
}

View file

@ -0,0 +1,20 @@
\\ Repeat a string str the specified number of times ntimes and return composed string.
\\ 3/3/2016 aev
srepeat(str,ntimes)={
my(srez=str,nt=ntimes-1);
if(ntimes<1||#str==0,return(""));
if(ntimes==1,return(str));
for(i=1,nt, srez=concat(srez,str));
return(srez);
}
{
\\ TESTS
print(" *** Testing srepeat:");
print("1.",srepeat("a",5));
print("2.",srepeat("ab",5));
print("3.",srepeat("c",1));
print("4.|",srepeat("d",0),"|");
print("5.|",srepeat("",5),"|");
print1("6."); for(i=1,10000000, srepeat("e",10));
}