\\ 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)); }