Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Repeat-a-string/00-META.yaml
Normal file
3
Task/Repeat-a-string/00-META.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
from: http://rosettacode.org/wiki/Repeat_a_string
|
||||
note: String manipulation
|
||||
10
Task/Repeat-a-string/00-TASK.txt
Normal file
10
Task/Repeat-a-string/00-TASK.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
Take a string and repeat it some number of times.
|
||||
|
||||
Example: repeat("ha", 5) => "hahahahaha"
|
||||
|
||||
If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****").
|
||||
|
||||
|
||||
{{Template:Strings}}
|
||||
<br><br>
|
||||
|
||||
1
Task/Repeat-a-string/11l/repeat-a-string.11l
Normal file
1
Task/Repeat-a-string/11l/repeat-a-string.11l
Normal file
|
|
@ -0,0 +1 @@
|
|||
print(‘ha’ * 5)
|
||||
43
Task/Repeat-a-string/360-Assembly/repeat-a-string.360
Normal file
43
Task/Repeat-a-string/360-Assembly/repeat-a-string.360
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
* Repeat a string - 19/04/2020
|
||||
REPEATS CSECT
|
||||
USING REPEATS,R13 base register
|
||||
B 72(R15) skip savearea
|
||||
DC 17F'0' savearea
|
||||
SAVE (14,12) save previous context
|
||||
ST R13,4(R15) link backward
|
||||
ST R15,8(R13) link forward
|
||||
LR R13,R15 set addressability
|
||||
XPRNT C24,24 print c24
|
||||
LA R1,PARMLST pg=repeat(cx,ii) - repeat('abc ',6)
|
||||
BAL R14,REPEAT call repeat
|
||||
XPRNT PG,L'PG print pg
|
||||
L R13,4(0,R13) restore previous savearea pointer
|
||||
RETURN (14,12),RC=0 restore registers from calling save
|
||||
REPEAT CNOP 0,4 procedure repeat(b,a,i)
|
||||
STM R2,R8,REPEATSA save registers
|
||||
L R2,0(R1) @b=%r1
|
||||
L R3,4(R1) @a=%(r1+4)
|
||||
L R4,8(R1) @i=%(r1+8)
|
||||
LR R5,R3 length(a) before a
|
||||
SH R5,=H'2' @lengh(a)
|
||||
LH R6,0(R5) l=length(a)
|
||||
LR R7,R6 l
|
||||
BCTR R7,0 l-1
|
||||
L R8,0(R4) i=%r4
|
||||
LTR R8,R8 if i<=0
|
||||
BNP RET then return
|
||||
LOOP EX R7,MVCX move a to b len R6
|
||||
AR R2,R6 @b+=l
|
||||
BCT R8,LOOP loop i times
|
||||
RET LM R2,R8,REPEATSA restore registers
|
||||
BR R14 return
|
||||
PARMLST DC A(PG,CX,II) parmlist
|
||||
REPEATSA DS 7F local savearea
|
||||
MVCX MVC 0(0,R2),0(R3) move @ R3 to @ R2
|
||||
C24 DC 6C'xyz ' constant repeat - repeat('xyz ',6)
|
||||
LCX DC AL2(L'CX) lengh(cc)
|
||||
CX DC CL4'abc ' cx
|
||||
II DC F'6' ii
|
||||
PG DC CL80' ' pg
|
||||
REGEQU
|
||||
END REPEATS
|
||||
10
Task/Repeat-a-string/4DOS-Batch/repeat-a-string.4dos
Normal file
10
Task/Repeat-a-string/4DOS-Batch/repeat-a-string.4dos
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
gosub repeat ha 5
|
||||
echo %@repeat[*,5]
|
||||
quit
|
||||
|
||||
:Repeat [String Times]
|
||||
do %Times%
|
||||
echos %String%
|
||||
enddo
|
||||
echo.
|
||||
return
|
||||
43
Task/Repeat-a-string/6502-Assembly/repeat-a-string.6502
Normal file
43
Task/Repeat-a-string/6502-Assembly/repeat-a-string.6502
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
CHROUT equ $FFD2 ;KERNAL call, prints the accumulator to the screen as an ascii value.
|
||||
|
||||
org $0801
|
||||
|
||||
|
||||
db $0E,$08,$0A,$00,$9E,$20,$28,$32,$30,$36,$34,$29,$00,$00,$00
|
||||
|
||||
|
||||
|
||||
|
||||
lda #>TestStr
|
||||
sta $11
|
||||
|
||||
lda #<TestStr
|
||||
sta $10
|
||||
|
||||
|
||||
ldx #5 ;number of times to repeat
|
||||
|
||||
loop:
|
||||
jsr PrintString
|
||||
dex
|
||||
bne loop
|
||||
|
||||
|
||||
RTS ;RETURN TO BASIC
|
||||
|
||||
|
||||
PrintString:
|
||||
ldy #0
|
||||
loop_PrintString:
|
||||
lda ($10),y ;this doesn't actually increment the pointer itself, so we don't need to back it up.
|
||||
beq donePrinting
|
||||
jsr CHROUT
|
||||
iny
|
||||
jmp loop_PrintString
|
||||
donePrinting:
|
||||
rts
|
||||
|
||||
|
||||
|
||||
TestStr:
|
||||
db "HA",0
|
||||
12
Task/Repeat-a-string/68000-Assembly/repeat-a-string.68000
Normal file
12
Task/Repeat-a-string/68000-Assembly/repeat-a-string.68000
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
MOVE.W #5-1,D1
|
||||
RepString:
|
||||
LEA A3, MyString
|
||||
MOVE.L A3,-(SP) ;PUSH A3
|
||||
JSR PrintString ;unimplemented hardware-dependent printing routine, assumed to not clobber D1
|
||||
MOVE.L (SP)+,A3 ;POP A3
|
||||
DBRA D1,RepString
|
||||
RTS ;return to basic or whatever
|
||||
|
||||
MyString:
|
||||
DC.B "ha",0
|
||||
even
|
||||
2
Task/Repeat-a-string/8th/repeat-a-string.8th
Normal file
2
Task/Repeat-a-string/8th/repeat-a-string.8th
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
"ha" 5 s:*
|
||||
. cr
|
||||
3
Task/Repeat-a-string/ABAP/repeat-a-string.abap
Normal file
3
Task/Repeat-a-string/ABAP/repeat-a-string.abap
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
report z_repeat_string.
|
||||
|
||||
write repeat( val = `ha` occ = 5 ).
|
||||
1
Task/Repeat-a-string/ALGOL-68/repeat-a-string.alg
Normal file
1
Task/Repeat-a-string/ALGOL-68/repeat-a-string.alg
Normal file
|
|
@ -0,0 +1 @@
|
|||
print (5 * "ha")
|
||||
2
Task/Repeat-a-string/APL/repeat-a-string-1.apl
Normal file
2
Task/Repeat-a-string/APL/repeat-a-string-1.apl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
10⍴'ha'
|
||||
hahahahaha
|
||||
3
Task/Repeat-a-string/APL/repeat-a-string-2.apl
Normal file
3
Task/Repeat-a-string/APL/repeat-a-string-2.apl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
REPEAT←{(⍺×⍴⍵)⍴⍵}
|
||||
5 REPEAT 'ha'
|
||||
hahahahaha
|
||||
10
Task/Repeat-a-string/AWK/repeat-a-string.awk
Normal file
10
Task/Repeat-a-string/AWK/repeat-a-string.awk
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
function repeat( str, n, rep, i )
|
||||
{
|
||||
for( ; i<n; i++ )
|
||||
rep = rep str
|
||||
return rep
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
print repeat( "ha", 5 )
|
||||
}
|
||||
11
Task/Repeat-a-string/Action-/repeat-a-string.action
Normal file
11
Task/Repeat-a-string/Action-/repeat-a-string.action
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Proc Main()
|
||||
byte REPEAT
|
||||
|
||||
REPEAT=5
|
||||
Do
|
||||
Print("ha")
|
||||
REPEAT==-1
|
||||
Until REPEAT=0
|
||||
Do
|
||||
|
||||
Return
|
||||
7
Task/Repeat-a-string/ActionScript/repeat-a-string-1.as
Normal file
7
Task/Repeat-a-string/ActionScript/repeat-a-string-1.as
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
function repeatString(string:String, numTimes:uint):String
|
||||
{
|
||||
var output:String = "";
|
||||
for(var i:uint = 0; i < numTimes; i++)
|
||||
output += string;
|
||||
return output;
|
||||
}
|
||||
7
Task/Repeat-a-string/ActionScript/repeat-a-string-2.as
Normal file
7
Task/Repeat-a-string/ActionScript/repeat-a-string-2.as
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
function repeatRecursive(string:String, numTimes:uint):String
|
||||
{
|
||||
if(numTimes == 0) return "";
|
||||
if(numTimes & 1) return string + repeatRecursive(string, numTimes - 1);
|
||||
var tmp:String = repeatRecursive(string, numTimes/2);
|
||||
return tmp + tmp;
|
||||
}
|
||||
2
Task/Repeat-a-string/ActionScript/repeat-a-string-3.as
Normal file
2
Task/Repeat-a-string/ActionScript/repeat-a-string-3.as
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import mx.utils.StringUtil;
|
||||
trace(StringUtil.repeat("ha", 5));
|
||||
7
Task/Repeat-a-string/Ada/repeat-a-string.ada
Normal file
7
Task/Repeat-a-string/Ada/repeat-a-string.ada
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure String_Multiplication is
|
||||
begin
|
||||
Put_Line (5 * "ha");
|
||||
end String_Multiplication;
|
||||
1
Task/Repeat-a-string/Aime/repeat-a-string.aime
Normal file
1
Task/Repeat-a-string/Aime/repeat-a-string.aime
Normal file
|
|
@ -0,0 +1 @@
|
|||
call_n(5, o_text, "ha");
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/hopper
|
||||
#include <hopper.h>
|
||||
|
||||
main:
|
||||
{"ha"}replyby(5), println
|
||||
{"ha",5}replicate, println
|
||||
{0}return
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
set str to "ha"
|
||||
set final_string to ""
|
||||
repeat 5 times
|
||||
set final_string to final_string & str
|
||||
end repeat
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
replicate(5000, "ha")
|
||||
|
||||
-- Repetition by 'Egyptian multiplication' -
|
||||
-- progressively doubling a list, appending
|
||||
-- stages of doubling to an accumulator where needed for
|
||||
-- binary assembly of a target length.
|
||||
|
||||
-- replicate :: Int -> String -> String
|
||||
on replicate(n, s)
|
||||
set out to ""
|
||||
if n < 1 then return out
|
||||
set dbl to s
|
||||
|
||||
repeat while (n > 1)
|
||||
if (n mod 2) > 0 then set out to out & dbl
|
||||
set n to (n div 2)
|
||||
set dbl to (dbl & dbl)
|
||||
end repeat
|
||||
return out & dbl
|
||||
end replicate
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
FOR I = 1 TO 5 : S$ = S$ + "HA" : NEXT
|
||||
|
||||
? "X" SPC(20) "X"
|
||||
1
Task/Repeat-a-string/Arturo/repeat-a-string.arturo
Normal file
1
Task/Repeat-a-string/Arturo/repeat-a-string.arturo
Normal file
|
|
@ -0,0 +1 @@
|
|||
print repeat "ha" 5
|
||||
8
Task/Repeat-a-string/AutoHotkey/repeat-a-string.ahk
Normal file
8
Task/Repeat-a-string/AutoHotkey/repeat-a-string.ahk
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
MsgBox % Repeat("ha",5)
|
||||
|
||||
Repeat(String,Times)
|
||||
{
|
||||
Loop, %Times%
|
||||
Output .= String
|
||||
Return Output
|
||||
}
|
||||
3
Task/Repeat-a-string/AutoIt/repeat-a-string.autoit
Normal file
3
Task/Repeat-a-string/AutoIt/repeat-a-string.autoit
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#include <String.au3>
|
||||
|
||||
ConsoleWrite(_StringRepeat("ha", 5) & @CRLF)
|
||||
12
Task/Repeat-a-string/BASIC256/repeat-a-string.basic
Normal file
12
Task/Repeat-a-string/BASIC256/repeat-a-string.basic
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function StringRepeat$ (s$, n)
|
||||
cad$ = ""
|
||||
for i = 1 to n
|
||||
cad$ += s$
|
||||
next i
|
||||
return cad$
|
||||
end function
|
||||
|
||||
print StringRepeat$("rosetta", 1)
|
||||
print StringRepeat$("ha", 5)
|
||||
print StringRepeat$("*", 5)
|
||||
end
|
||||
1
Task/Repeat-a-string/BBC-BASIC/repeat-a-string.basic
Normal file
1
Task/Repeat-a-string/BBC-BASIC/repeat-a-string.basic
Normal file
|
|
@ -0,0 +1 @@
|
|||
PRINT STRING$(5, "ha")
|
||||
3
Task/Repeat-a-string/BQN/repeat-a-string-1.bqn
Normal file
3
Task/Repeat-a-string/BQN/repeat-a-string-1.bqn
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Repeat ← ×⟜≠ ⥊ ⊢
|
||||
|
||||
•Show 5 Repeat "Hello"
|
||||
1
Task/Repeat-a-string/BQN/repeat-a-string-2.bqn
Normal file
1
Task/Repeat-a-string/BQN/repeat-a-string-2.bqn
Normal file
|
|
@ -0,0 +1 @@
|
|||
"HelloHelloHelloHelloHello"
|
||||
4
Task/Repeat-a-string/BaCon/repeat-a-string-1.bacon
Normal file
4
Task/Repeat-a-string/BaCon/repeat-a-string-1.bacon
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
DOTIMES 5
|
||||
s$ = s$ & "ha"
|
||||
DONE
|
||||
PRINT s$
|
||||
1
Task/Repeat-a-string/BaCon/repeat-a-string-2.bacon
Normal file
1
Task/Repeat-a-string/BaCon/repeat-a-string-2.bacon
Normal file
|
|
@ -0,0 +1 @@
|
|||
PRINT FILL$(5, ASC("x"))
|
||||
3
Task/Repeat-a-string/Babel/repeat-a-string-1.pb
Normal file
3
Task/Repeat-a-string/Babel/repeat-a-string-1.pb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
main: { "ha" 5 print_repeat }
|
||||
|
||||
print_repeat!: { <- { dup << } -> times }
|
||||
1
Task/Repeat-a-string/Babel/repeat-a-string-2.pb
Normal file
1
Task/Repeat-a-string/Babel/repeat-a-string-2.pb
Normal file
|
|
@ -0,0 +1 @@
|
|||
hahahahaha
|
||||
8
Task/Repeat-a-string/Batch-File/repeat-a-string-1.bat
Normal file
8
Task/Repeat-a-string/Batch-File/repeat-a-string-1.bat
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
@echo off
|
||||
if "%2" equ "" goto fail
|
||||
setlocal enabledelayedexpansion
|
||||
set char=%1
|
||||
set num=%2
|
||||
for /l %%i in (1,1,%num%) do set res=!res!%char%
|
||||
echo %res%
|
||||
:fail
|
||||
10
Task/Repeat-a-string/Batch-File/repeat-a-string-2.bat
Normal file
10
Task/Repeat-a-string/Batch-File/repeat-a-string-2.bat
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
@echo off
|
||||
set /p a=Enter string to repeat :
|
||||
set /p b=Enter how many times to repeat :
|
||||
set "c=1"
|
||||
set "d=%b%"
|
||||
:a
|
||||
echo %a%
|
||||
set "c=%c%+=1"
|
||||
if /i _"%c%"==_"%d%" (exit /b)
|
||||
goto :a
|
||||
13
Task/Repeat-a-string/Batch-File/repeat-a-string-3.bat
Normal file
13
Task/Repeat-a-string/Batch-File/repeat-a-string-3.bat
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
@echo off
|
||||
@FOR /L %%i in (0,1,9) DO @CALL :REPEAT %%i
|
||||
@echo That's it!
|
||||
@FOR /L %%i in (0,1,9) DO @CALL :REPEAT %%i
|
||||
@echo.
|
||||
@echo And that!
|
||||
@GOTO END
|
||||
|
||||
:REPEAT
|
||||
@echo|set /p="*"
|
||||
@GOTO:EOF
|
||||
|
||||
:END
|
||||
2
Task/Repeat-a-string/Beef/repeat-a-string-1.beef
Normal file
2
Task/Repeat-a-string/Beef/repeat-a-string-1.beef
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
String s = new String('X', 5);
|
||||
s.Replace("X", "ha");
|
||||
2
Task/Repeat-a-string/Beef/repeat-a-string-2.beef
Normal file
2
Task/Repeat-a-string/Beef/repeat-a-string-2.beef
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
String s1 = scope .();
|
||||
s1.PadLeft(5, '*');
|
||||
3
Task/Repeat-a-string/Beeswax/repeat-a-string.beeswax
Normal file
3
Task/Repeat-a-string/Beeswax/repeat-a-string.beeswax
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
p <
|
||||
p0~1<}~< d@<
|
||||
_VT@1~>yg~9PKd@M'd;
|
||||
4
Task/Repeat-a-string/Befunge/repeat-a-string.bf
Normal file
4
Task/Repeat-a-string/Befunge/repeat-a-string.bf
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
v> ">:#,_v
|
||||
>29*+00p>~:"0"- #v_v $
|
||||
v ^p0p00:-1g00< $ >
|
||||
v p00&p0-1g00+4*65< >00g1-:00p#^_@
|
||||
8
Task/Repeat-a-string/Bracmat/repeat-a-string.bracmat
Normal file
8
Task/Repeat-a-string/Bracmat/repeat-a-string.bracmat
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(repeat=
|
||||
string N rep
|
||||
. !arg:(?string.?N)
|
||||
& !string:?rep
|
||||
& whl
|
||||
' (!N+-1:>0:?N&!string !rep:?rep)
|
||||
& str$!rep
|
||||
);
|
||||
9
Task/Repeat-a-string/Brainf---/repeat-a-string.bf
Normal file
9
Task/Repeat-a-string/Brainf---/repeat-a-string.bf
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
+++++ +++++ init first as 10 counter
|
||||
[-> +++++ +++++<] we add 10 to second each loopround
|
||||
|
||||
Now we want to loop 5 times to follow std
|
||||
+++++
|
||||
[-> ++++ . ----- -- . +++<] print h and a each loop
|
||||
|
||||
and a newline because I'm kind and it looks good
|
||||
+++++ +++++ +++ . --- .
|
||||
1
Task/Repeat-a-string/Brat/repeat-a-string.brat
Normal file
1
Task/Repeat-a-string/Brat/repeat-a-string.brat
Normal file
|
|
@ -0,0 +1 @@
|
|||
p "ha" * 5 #Prints "hahahahaha"
|
||||
4
Task/Repeat-a-string/Burlesque/repeat-a-string.blq
Normal file
4
Task/Repeat-a-string/Burlesque/repeat-a-string.blq
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
blsq ) 'h5?*
|
||||
"hhhhh"
|
||||
blsq ) "ha"5.*\[
|
||||
"hahahahaha"
|
||||
15
Task/Repeat-a-string/C++/repeat-a-string-1.cpp
Normal file
15
Task/Repeat-a-string/C++/repeat-a-string-1.cpp
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
std::string repeat( const std::string &word, int times ) {
|
||||
std::string result ;
|
||||
result.reserve(times*word.length()); // avoid repeated reallocation
|
||||
for ( int a = 0 ; a < times ; a++ )
|
||||
result += word ;
|
||||
return result ;
|
||||
}
|
||||
|
||||
int main( ) {
|
||||
std::cout << repeat( "Ha" , 5 ) << std::endl ;
|
||||
return 0 ;
|
||||
}
|
||||
7
Task/Repeat-a-string/C++/repeat-a-string-2.cpp
Normal file
7
Task/Repeat-a-string/C++/repeat-a-string-2.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
int main( ) {
|
||||
std::cout << std::string( 5, '*' ) << std::endl ;
|
||||
return 0 ;
|
||||
}
|
||||
16
Task/Repeat-a-string/C++/repeat-a-string-3.cpp
Normal file
16
Task/Repeat-a-string/C++/repeat-a-string-3.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
std::string repeat( const std::string &word, uint times ) {
|
||||
return
|
||||
times == 0 ? "" :
|
||||
times == 1 ? word :
|
||||
times == 2 ? word + word :
|
||||
repeat(repeat(word, times / 2), 2) +
|
||||
repeat(word, times % 2);
|
||||
}
|
||||
|
||||
int main( ) {
|
||||
std::cout << repeat( "Ha" , 5 ) << std::endl ;
|
||||
return 0 ;
|
||||
}
|
||||
1
Task/Repeat-a-string/C-sharp/repeat-a-string-1.cs
Normal file
1
Task/Repeat-a-string/C-sharp/repeat-a-string-1.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
string s = "".PadLeft(5, 'X').Replace("X", "ha");
|
||||
1
Task/Repeat-a-string/C-sharp/repeat-a-string-2.cs
Normal file
1
Task/Repeat-a-string/C-sharp/repeat-a-string-2.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
string s = new String('X', 5).Replace("X", "ha");
|
||||
1
Task/Repeat-a-string/C-sharp/repeat-a-string-3.cs
Normal file
1
Task/Repeat-a-string/C-sharp/repeat-a-string-3.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
string s = String.Join("ha", new string[5 + 1]);
|
||||
1
Task/Repeat-a-string/C-sharp/repeat-a-string-4.cs
Normal file
1
Task/Repeat-a-string/C-sharp/repeat-a-string-4.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
string s = String.Concat(Enumerable.Repeat("ha", 5));
|
||||
1
Task/Repeat-a-string/C-sharp/repeat-a-string-5.cs
Normal file
1
Task/Repeat-a-string/C-sharp/repeat-a-string-5.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
string s = "".PadLeft(5, '*');
|
||||
1
Task/Repeat-a-string/C-sharp/repeat-a-string-6.cs
Normal file
1
Task/Repeat-a-string/C-sharp/repeat-a-string-6.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
string s = new String('*', 5);
|
||||
22
Task/Repeat-a-string/C/repeat-a-string-1.c
Normal file
22
Task/Repeat-a-string/C/repeat-a-string-1.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char * string_repeat( int n, const char * s ) {
|
||||
size_t slen = strlen(s);
|
||||
char * dest = malloc(n*slen+1);
|
||||
|
||||
int i; char * p;
|
||||
for ( i=0, p = dest; i < n; ++i, p += slen ) {
|
||||
memcpy(p, s, slen);
|
||||
}
|
||||
*p = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
int main() {
|
||||
char * result = string_repeat(5, "ha");
|
||||
puts(result);
|
||||
free(result);
|
||||
return 0;
|
||||
}
|
||||
13
Task/Repeat-a-string/C/repeat-a-string-2.c
Normal file
13
Task/Repeat-a-string/C/repeat-a-string-2.c
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
...
|
||||
char *string_repeat(const char *str, int n)
|
||||
{
|
||||
char *pa, *pb;
|
||||
size_t slen = strlen(str);
|
||||
char *dest = malloc(n*slen+1);
|
||||
|
||||
pa = dest + (n-1)*slen;
|
||||
strcpy(pa, str);
|
||||
pb = --pa + slen;
|
||||
while (pa>=dest) *pa-- = *pb--;
|
||||
return dest;
|
||||
}
|
||||
17
Task/Repeat-a-string/C/repeat-a-string-3.c
Normal file
17
Task/Repeat-a-string/C/repeat-a-string-3.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char * char_repeat( int n, char c ) {
|
||||
char * dest = malloc(n+1);
|
||||
memset(dest, c, n);
|
||||
dest[n] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
int main() {
|
||||
char * result = char_repeat(5, '*');
|
||||
puts(result);
|
||||
free(result);
|
||||
return 0;
|
||||
}
|
||||
9
Task/Repeat-a-string/COBOL/repeat-a-string.cobol
Normal file
9
Task/Repeat-a-string/COBOL/repeat-a-string.cobol
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. REPEAT-PROGRAM.
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
77 HAHA PIC A(10).
|
||||
PROCEDURE DIVISION.
|
||||
MOVE ALL 'ha' TO HAHA.
|
||||
DISPLAY HAHA.
|
||||
STOP RUN.
|
||||
3
Task/Repeat-a-string/Ceylon/repeat-a-string.ceylon
Normal file
3
Task/Repeat-a-string/Ceylon/repeat-a-string.ceylon
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
shared void repeatAString() {
|
||||
print("ha".repeat(5));
|
||||
}
|
||||
1
Task/Repeat-a-string/Clipper/repeat-a-string.clipper
Normal file
1
Task/Repeat-a-string/Clipper/repeat-a-string.clipper
Normal file
|
|
@ -0,0 +1 @@
|
|||
Replicate( "Ha", 5 )
|
||||
1
Task/Repeat-a-string/Clojure/repeat-a-string.clj
Normal file
1
Task/Repeat-a-string/Clojure/repeat-a-string.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(apply str (repeat 5 "ha"))
|
||||
5
Task/Repeat-a-string/ColdFusion/repeat-a-string.cfm
Normal file
5
Task/Repeat-a-string/ColdFusion/repeat-a-string.cfm
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<cfset word = 'ha'>
|
||||
<Cfset n = 5>
|
||||
<Cfoutput>
|
||||
<Cfloop from="1" to="#n#" index="i">#word#</Cfloop>
|
||||
</Cfoutput>
|
||||
3
Task/Repeat-a-string/Common-Lisp/repeat-a-string-1.lisp
Normal file
3
Task/Repeat-a-string/Common-Lisp/repeat-a-string-1.lisp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(defun repeat-string (n string)
|
||||
(with-output-to-string (stream)
|
||||
(loop repeat n do (write-string string stream))))
|
||||
9
Task/Repeat-a-string/Common-Lisp/repeat-a-string-2.lisp
Normal file
9
Task/Repeat-a-string/Common-Lisp/repeat-a-string-2.lisp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(defun repeat-string (n string
|
||||
&aux
|
||||
(len (length string))
|
||||
(result (make-string (* n len)
|
||||
:element-type (array-element-type string))))
|
||||
(loop repeat n
|
||||
for i from 0 by len
|
||||
do (setf (subseq result i (+ i len)) string))
|
||||
result)
|
||||
2
Task/Repeat-a-string/Common-Lisp/repeat-a-string-3.lisp
Normal file
2
Task/Repeat-a-string/Common-Lisp/repeat-a-string-3.lisp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(defun repeat-string (n string)
|
||||
(format nil "~V@{~a~:*~}" n string))
|
||||
1
Task/Repeat-a-string/Common-Lisp/repeat-a-string-4.lisp
Normal file
1
Task/Repeat-a-string/Common-Lisp/repeat-a-string-4.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(princ (repeat-string 5 "hi"))
|
||||
1
Task/Repeat-a-string/Common-Lisp/repeat-a-string-5.lisp
Normal file
1
Task/Repeat-a-string/Common-Lisp/repeat-a-string-5.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(make-string 5 :initial-element #\X)
|
||||
1
Task/Repeat-a-string/Crystal/repeat-a-string.crystal
Normal file
1
Task/Repeat-a-string/Crystal/repeat-a-string.crystal
Normal file
|
|
@ -0,0 +1 @@
|
|||
puts "ha" * 5
|
||||
5
Task/Repeat-a-string/D/repeat-a-string-1.d
Normal file
5
Task/Repeat-a-string/D/repeat-a-string-1.d
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import std.stdio, std.array;
|
||||
|
||||
void main() {
|
||||
writeln("ha".replicate(5));
|
||||
}
|
||||
8
Task/Repeat-a-string/D/repeat-a-string-2.d
Normal file
8
Task/Repeat-a-string/D/repeat-a-string-2.d
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import std.stdio;
|
||||
|
||||
void main() {
|
||||
char[] chars; // create the dynamic array
|
||||
chars.length = 5; // set the length
|
||||
chars[] = '*'; // set all characters in the string to '*'
|
||||
writeln(chars);
|
||||
}
|
||||
2
Task/Repeat-a-string/DCL/repeat-a-string.dcl
Normal file
2
Task/Repeat-a-string/DCL/repeat-a-string.dcl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$ write sys$output f$fao( "!AS!-!AS!-!AS!-!AS!-!AS", "ha" )
|
||||
$ write sys$output f$fao( "!12*d" )
|
||||
1
Task/Repeat-a-string/DWScript/repeat-a-string-1.dw
Normal file
1
Task/Repeat-a-string/DWScript/repeat-a-string-1.dw
Normal file
|
|
@ -0,0 +1 @@
|
|||
PrintLn( StringOfString('abc',5) );
|
||||
1
Task/Repeat-a-string/DWScript/repeat-a-string-2.dw
Normal file
1
Task/Repeat-a-string/DWScript/repeat-a-string-2.dw
Normal file
|
|
@ -0,0 +1 @@
|
|||
PrintLn( StringOfChar('a',5) );
|
||||
9
Task/Repeat-a-string/Delphi/repeat-a-string-1.delphi
Normal file
9
Task/Repeat-a-string/Delphi/repeat-a-string-1.delphi
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
function RepeatString(const s: string; count: cardinal): string;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 1 to count do
|
||||
Result := Result + s;
|
||||
end;
|
||||
|
||||
Writeln(RepeatString('ha',5));
|
||||
1
Task/Repeat-a-string/Delphi/repeat-a-string-2.delphi
Normal file
1
Task/Repeat-a-string/Delphi/repeat-a-string-2.delphi
Normal file
|
|
@ -0,0 +1 @@
|
|||
Writeln( StringOfChar('a',5) );
|
||||
7
Task/Repeat-a-string/Delphi/repeat-a-string-3.delphi
Normal file
7
Task/Repeat-a-string/Delphi/repeat-a-string-3.delphi
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
function RepeatStr(const s: string; i: Cardinal): string;
|
||||
begin
|
||||
if i = 0 then
|
||||
result := ''
|
||||
else
|
||||
result := s + RepeatStr(s, i-1)
|
||||
end;
|
||||
1
Task/Repeat-a-string/Delphi/repeat-a-string-4.delphi
Normal file
1
Task/Repeat-a-string/Delphi/repeat-a-string-4.delphi
Normal file
|
|
@ -0,0 +1 @@
|
|||
StrUtils.DupeString
|
||||
1
Task/Repeat-a-string/Dyalect/repeat-a-string.dyalect
Normal file
1
Task/Repeat-a-string/Dyalect/repeat-a-string.dyalect
Normal file
|
|
@ -0,0 +1 @@
|
|||
String.Repeat("ha", 5)
|
||||
1
Task/Repeat-a-string/E/repeat-a-string.e
Normal file
1
Task/Repeat-a-string/E/repeat-a-string.e
Normal file
|
|
@ -0,0 +1 @@
|
|||
"ha" * 5
|
||||
5
Task/Repeat-a-string/ECL/repeat-a-string-1.ecl
Normal file
5
Task/Repeat-a-string/ECL/repeat-a-string-1.ecl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
IMPORT STD; //Imports the Standard Library
|
||||
|
||||
STRING MyBaseString := 'abc';
|
||||
RepeatedString := STD.Str.Repeat(MyBaseString,3);
|
||||
RepeatedString; //returns 'abcabcabc'
|
||||
9
Task/Repeat-a-string/ECL/repeat-a-string-2.ecl
Normal file
9
Task/Repeat-a-string/ECL/repeat-a-string-2.ecl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
RepeatString(STRING InStr, INTEGER Cnt) := FUNCTION
|
||||
rec := {STRING Str};
|
||||
ds := DATASET(Cnt,TRANSFORM(rec,SELF.Str := InStr));
|
||||
res := ITERATE(ds,TRANSFORM(rec,SELF.Str := LEFT.Str + RIGHT.Str));
|
||||
RETURN Res[Cnt].Str;
|
||||
END;
|
||||
|
||||
RepeatString('ha',3);
|
||||
RepeatString('Who',2);
|
||||
7
Task/Repeat-a-string/ERRE/repeat-a-string.erre
Normal file
7
Task/Repeat-a-string/ERRE/repeat-a-string.erre
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
PROCEDURE REPEAT_STRING(S$,N%->REP$)
|
||||
LOCAL I%
|
||||
REP$=""
|
||||
FOR I%=1 TO N% DO
|
||||
REP$=REP$+S$
|
||||
END FOR
|
||||
END PROCEDURE
|
||||
2
Task/Repeat-a-string/Ecstasy/repeat-a-string.ecstasy
Normal file
2
Task/Repeat-a-string/Ecstasy/repeat-a-string.ecstasy
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
String funny = "ha" * 5;
|
||||
String stars = '*' * 80;
|
||||
1
Task/Repeat-a-string/Egison/repeat-a-string.egison
Normal file
1
Task/Repeat-a-string/Egison/repeat-a-string.egison
Normal file
|
|
@ -0,0 +1 @@
|
|||
(S.concat (take 5 (repeat1 "ha")))
|
||||
6
Task/Repeat-a-string/Eiffel/repeat-a-string.e
Normal file
6
Task/Repeat-a-string/Eiffel/repeat-a-string.e
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
repeat_string(a_string: STRING; times: INTEGER): STRING
|
||||
require
|
||||
times_positive: times > 0
|
||||
do
|
||||
Result := a_string.multiply(times)
|
||||
end
|
||||
8
Task/Repeat-a-string/Elena/repeat-a-string.elena
Normal file
8
Task/Repeat-a-string/Elena/repeat-a-string.elena
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import system'routines;
|
||||
import extensions;
|
||||
import extensions'text;
|
||||
|
||||
public program()
|
||||
{
|
||||
var s := new Range(0, 5).selectBy:(x => "ha").summarize(new StringWriter())
|
||||
}
|
||||
1
Task/Repeat-a-string/Elixir/repeat-a-string.elixir
Normal file
1
Task/Repeat-a-string/Elixir/repeat-a-string.elixir
Normal file
|
|
@ -0,0 +1 @@
|
|||
String.duplicate("ha", 5)
|
||||
1
Task/Repeat-a-string/Emacs-Lisp/repeat-a-string-1.l
Normal file
1
Task/Repeat-a-string/Emacs-Lisp/repeat-a-string-1.l
Normal file
|
|
@ -0,0 +1 @@
|
|||
(apply 'concat (make-list 5 "ha"))
|
||||
1
Task/Repeat-a-string/Emacs-Lisp/repeat-a-string-2.l
Normal file
1
Task/Repeat-a-string/Emacs-Lisp/repeat-a-string-2.l
Normal file
|
|
@ -0,0 +1 @@
|
|||
(make-string 5 ?x)
|
||||
2
Task/Repeat-a-string/Emacs-Lisp/repeat-a-string-3.l
Normal file
2
Task/Repeat-a-string/Emacs-Lisp/repeat-a-string-3.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(require 'cl-lib)
|
||||
(cl-loop repeat 5 concat "ha")
|
||||
2
Task/Repeat-a-string/Erlang/repeat-a-string.erl
Normal file
2
Task/Repeat-a-string/Erlang/repeat-a-string.erl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
repeat(X,N) ->
|
||||
lists:flatten(lists:duplicate(N,X)).
|
||||
5
Task/Repeat-a-string/Euphoria/repeat-a-string-1.euphoria
Normal file
5
Task/Repeat-a-string/Euphoria/repeat-a-string-1.euphoria
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
sequence s = ""
|
||||
for i = 1 to 5 do s &= "ha" end for
|
||||
puts(1,s)
|
||||
|
||||
hahahahaha
|
||||
3
Task/Repeat-a-string/Euphoria/repeat-a-string-2.euphoria
Normal file
3
Task/Repeat-a-string/Euphoria/repeat-a-string-2.euphoria
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
sequence s = repeat('*',5)
|
||||
|
||||
*****
|
||||
9
Task/Repeat-a-string/Euphoria/repeat-a-string-3.euphoria
Normal file
9
Task/Repeat-a-string/Euphoria/repeat-a-string-3.euphoria
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
include std/console.e -- for display
|
||||
include std/sequence.e -- for repeat_pattern
|
||||
sequence s = repeat_pattern("ha",5)
|
||||
sequence n = repeat_pattern({1,2,3},5)
|
||||
display(s)
|
||||
display(n)
|
||||
|
||||
hahahahaha
|
||||
{1,2,3,1,2,3,1,2,3,1,2,3,1,2,3}
|
||||
4
Task/Repeat-a-string/Euphoria/repeat-a-string-4.euphoria
Normal file
4
Task/Repeat-a-string/Euphoria/repeat-a-string-4.euphoria
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
include std/console.e -- for display
|
||||
include std/sequence.e -- for flatten
|
||||
sequence s = flatten(repeat("ha",5))
|
||||
display(s)
|
||||
7
Task/Repeat-a-string/Euphoria/repeat-a-string-5.euphoria
Normal file
7
Task/Repeat-a-string/Euphoria/repeat-a-string-5.euphoria
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"ha",
|
||||
"ha",
|
||||
"ha",
|
||||
"ha",
|
||||
"ha"
|
||||
}
|
||||
2
Task/Repeat-a-string/F-Sharp/repeat-a-string-1.fs
Normal file
2
Task/Repeat-a-string/F-Sharp/repeat-a-string-1.fs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
> String.replicate 5 "ha";;
|
||||
val it : string = "hahahahaha"
|
||||
2
Task/Repeat-a-string/F-Sharp/repeat-a-string-2.fs
Normal file
2
Task/Repeat-a-string/F-Sharp/repeat-a-string-2.fs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
> String.Concat( Array.create 5 "ha" );;
|
||||
val it : string = "hahahahaha"
|
||||
3
Task/Repeat-a-string/Factor/repeat-a-string.factor
Normal file
3
Task/Repeat-a-string/Factor/repeat-a-string.factor
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
: repeat-string ( str n -- str' ) swap <repetition> concat ;
|
||||
|
||||
"ha" 5 repeat-string print
|
||||
6
Task/Repeat-a-string/Forth/repeat-a-string-1.fth
Normal file
6
Task/Repeat-a-string/Forth/repeat-a-string-1.fth
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
: place-n { src len dest n -- }
|
||||
0 dest c!
|
||||
n 0 ?do src len dest +place loop ;
|
||||
|
||||
s" ha" pad 5 place-n
|
||||
pad count type \ hahahahaha
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue