Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
6
Task/String-append/00-META.yaml
Normal file
6
Task/String-append/00-META.yaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
category:
|
||||
- String manipulation
|
||||
- String manipulation
|
||||
from: http://rosettacode.org/wiki/String_append
|
||||
note: Basic language learning
|
||||
13
Task/String-append/00-TASK.txt
Normal file
13
Task/String-append/00-TASK.txt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{{basic data operation}}
|
||||
[[Category:Simple]]
|
||||
|
||||
Most languages provide a way to concatenate two string values, but some languages also provide a convenient way to append in-place to an existing string variable without referring to the variable twice.
|
||||
|
||||
|
||||
;Task:
|
||||
Create a string variable equal to any text value.
|
||||
|
||||
Append the string variable with another string literal in the most idiomatic way, without double reference if your language supports it.
|
||||
|
||||
Show the contents of the variable after the append operation.
|
||||
<br><br>
|
||||
3
Task/String-append/11l/string-append.11l
Normal file
3
Task/String-append/11l/string-append.11l
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
V s = ‘12345678’
|
||||
s ‘’= ‘9!’
|
||||
print(s)
|
||||
86
Task/String-append/AArch64-Assembly/string-append.aarch64
Normal file
86
Task/String-append/AArch64-Assembly/string-append.aarch64
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/* ARM assembly AARCH64 Raspberry PI 3B */
|
||||
/* program appendstr64.s */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes file */
|
||||
/*******************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeConstantesARM64.inc"
|
||||
|
||||
.equ BUFFERSIZE, 100
|
||||
/*******************************************/
|
||||
/* Initialized data */
|
||||
/*******************************************/
|
||||
.data
|
||||
szMessString: .asciz "String :\n"
|
||||
szString1: .asciz "Alphabet : "
|
||||
sComplement: .fill BUFFERSIZE,1,0
|
||||
szString2: .asciz "abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
szCarriageReturn: .asciz "\n"
|
||||
/*******************************************/
|
||||
/* UnInitialized data */
|
||||
/*******************************************/
|
||||
.bss
|
||||
/*******************************************/
|
||||
/* code section */
|
||||
/*******************************************/
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
|
||||
ldr x0,qAdrszMessString // display message
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszString1 // display begin string
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszCarriageReturn // display return line
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszString1
|
||||
ldr x1,qAdrszString2
|
||||
bl append // append sting2 to string1
|
||||
ldr x0,qAdrszMessString
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszString1 // display string
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
|
||||
100: // standard end of the program
|
||||
mov x0,0 // return code
|
||||
mov x8,EXIT // request to exit program
|
||||
svc 0 // perform system call
|
||||
qAdrszMessString: .quad szMessString
|
||||
qAdrszString1: .quad szString1
|
||||
qAdrszString2: .quad szString2
|
||||
qAdrszCarriageReturn: .quad szCarriageReturn
|
||||
/**************************************************/
|
||||
/* append two strings */
|
||||
/**************************************************/
|
||||
/* x0 contains the address of the string1 */
|
||||
/* x1 contains the address of the string2 */
|
||||
append:
|
||||
stp x1,lr,[sp,-16]! // save registers
|
||||
mov x2,#0 // counter byte string 1
|
||||
1:
|
||||
ldrb w3,[x0,x2] // load byte string 1
|
||||
cmp x3,#0 // zero final ?
|
||||
add x4,x2,1
|
||||
csel x2,x4,x2,ne // if x3 not equal 0, x2 = X2 +1 else x2
|
||||
bne 1b // no -> loop
|
||||
mov x4,#0 // counter byte string 2
|
||||
2:
|
||||
ldrb w3,[x1,x4] // load byte string 2
|
||||
strb w3,[x0,x2] // store byte string 1
|
||||
cbz x3,100f // zero final ?
|
||||
add x2,x2,1 // no -> increment counter 1
|
||||
add x4,x4,1 // no -> increment counter 2
|
||||
b 2b // no -> loop
|
||||
100:
|
||||
|
||||
ldp x1,lr,[sp],16 // restaur 2 registers
|
||||
ret // return to address lr x30
|
||||
/********************************************************/
|
||||
/* File Include fonctions */
|
||||
/********************************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly */
|
||||
.include "../includeARM64.inc"
|
||||
6
Task/String-append/ALGOL-68/string-append.alg
Normal file
6
Task/String-append/ALGOL-68/string-append.alg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/a68g --script #
|
||||
# -*- coding: utf-8 -*- #
|
||||
|
||||
STRING str := "12345678";
|
||||
str +:= "9!";
|
||||
print(str)
|
||||
3
Task/String-append/APL/string-append.apl
Normal file
3
Task/String-append/APL/string-append.apl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
s←'hello'
|
||||
s,'world'
|
||||
helloworld
|
||||
95
Task/String-append/ARM-Assembly/string-append.arm
Normal file
95
Task/String-append/ARM-Assembly/string-append.arm
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program appendstr.s */
|
||||
|
||||
/* Constantes */
|
||||
.equ STDOUT, 1 @ Linux output console
|
||||
.equ EXIT, 1 @ Linux syscall
|
||||
.equ WRITE, 4 @ Linux syscall
|
||||
|
||||
.equ BUFFERSIZE, 100
|
||||
|
||||
/* Initialized data */
|
||||
.data
|
||||
szMessString: .asciz "String :\n"
|
||||
szString1: .asciz "Alphabet : "
|
||||
sComplement: .fill BUFFERSIZE,1,0
|
||||
szString2: .asciz "abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
szCarriageReturn: .asciz "\n"
|
||||
|
||||
/* UnInitialized data */
|
||||
.bss
|
||||
|
||||
/* code section */
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
|
||||
ldr r0,iAdrszMessString @ display message
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszString1 @ display begin string
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszCarriageReturn @ display line return
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszString1
|
||||
ldr r1,iAdrszString2
|
||||
bl append @ append sting2 to string1
|
||||
ldr r0,iAdrszMessString
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszString1 @ display string
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
|
||||
100: @ standard end of the program
|
||||
mov r0, #0 @ return code
|
||||
mov r7, #EXIT @ request to exit program
|
||||
svc 0 @ perform system call
|
||||
iAdrszMessString: .int szMessString
|
||||
iAdrszString1: .int szString1
|
||||
iAdrszString2: .int szString2
|
||||
iAdrszCarriageReturn: .int szCarriageReturn
|
||||
/******************************************************************/
|
||||
/* append two strings */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the string1 */
|
||||
/* r1 contains the address of the string2 */
|
||||
append:
|
||||
push {r0,r1,r2,r7,lr} @ save registers
|
||||
mov r2,#0 @ counter byte string 1
|
||||
1:
|
||||
ldrb r3,[r0,r2] @ load byte string 1
|
||||
cmp r3,#0 @ zero final ?
|
||||
addne r2,#1
|
||||
bne 1b @ no -> loop
|
||||
mov r4,#0 @ counter byte string 2
|
||||
2:
|
||||
ldrb r3,[r1,r4] @ load byte string 2
|
||||
strb r3,[r0,r2] @ store byte string 1
|
||||
cmp r3,#0 @ zero final ?
|
||||
addne r2,#1 @ no -> increment counter 1
|
||||
addne r4,#1 @ no -> increment counter 2
|
||||
bne 2b @ no -> loop
|
||||
100:
|
||||
pop {r0,r1,r2,r7,lr} @ restaur registers
|
||||
bx lr @ return
|
||||
|
||||
/******************************************************************/
|
||||
/* display text with size calculation */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the message */
|
||||
affichageMess:
|
||||
push {r0,r1,r2,r7,lr} @ save registers
|
||||
mov r2,#0 @ counter length */
|
||||
1: @ loop length calculation
|
||||
ldrb r1,[r0,r2] @ read octet start position + index
|
||||
cmp r1,#0 @ if 0 its over
|
||||
addne r2,r2,#1 @ else add 1 in the length
|
||||
bne 1b @ and loop
|
||||
@ so here r2 contains the length of the message
|
||||
mov r1,r0 @ address message in r1
|
||||
mov r0,#STDOUT @ code to write to the standard output Linux
|
||||
mov r7, #WRITE @ code call system "write"
|
||||
svc #0 @ call system
|
||||
pop {r0,r1,r2,r7,lr} @ restaur registers
|
||||
bx lr @ return
|
||||
7
Task/String-append/AWK/string-append.awk
Normal file
7
Task/String-append/AWK/string-append.awk
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# syntax: GAWK -f STRING_APPEND.AWK
|
||||
BEGIN {
|
||||
s = "foo"
|
||||
s = s "bar"
|
||||
print(s)
|
||||
exit(0)
|
||||
}
|
||||
8
Task/String-append/Action-/string-append.action
Normal file
8
Task/String-append/Action-/string-append.action
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
CHAR ARRAY S1,S2
|
||||
|
||||
Proc Main()
|
||||
S1="Hello, "
|
||||
S2="world!";
|
||||
Sassign(S1,S2,S1(0)+1)
|
||||
Print(S1)
|
||||
Return
|
||||
9
Task/String-append/Ada/string-append.ada
Normal file
9
Task/String-append/Ada/string-append.ada
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
|
||||
with Ada.Text_IO.Unbounded_Io; use Ada.Text_IO.Unbounded_IO;
|
||||
|
||||
procedure String_Append is
|
||||
Str : Unbounded_String := To_Unbounded_String("Hello");
|
||||
begin
|
||||
Append(Str, ", world!");
|
||||
Put_Line(Str);
|
||||
end String_Append;
|
||||
3
Task/String-append/AppleScript/string-append.applescript
Normal file
3
Task/String-append/AppleScript/string-append.applescript
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
set {a, b} to {"Apple", "Script"}
|
||||
set a to a & b
|
||||
return a as string
|
||||
3
Task/String-append/Applesoft-BASIC/string-append.basic
Normal file
3
Task/String-append/Applesoft-BASIC/string-append.basic
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
S$ = "Hello"
|
||||
S$ = S$ + " World!"
|
||||
PRINT S$
|
||||
12
Task/String-append/Arturo/string-append.arturo
Normal file
12
Task/String-append/Arturo/string-append.arturo
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
print join ["Hello" "World"]
|
||||
|
||||
a: new "Hello"
|
||||
'a ++ "World"
|
||||
print a
|
||||
|
||||
b: new "Hello"
|
||||
append 'b "World"
|
||||
print b
|
||||
|
||||
c: "Hello"
|
||||
print append c "World"
|
||||
4
Task/String-append/Asymptote/string-append.asymptote
Normal file
4
Task/String-append/Asymptote/string-append.asymptote
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
string s = "Hello";
|
||||
s = s + " Wo";
|
||||
s += "rld!";
|
||||
write(s);
|
||||
3
Task/String-append/AutoHotkey/string-append.ahk
Normal file
3
Task/String-append/AutoHotkey/string-append.ahk
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
s := "Hello, "
|
||||
s .= "world."
|
||||
MsgBox % s
|
||||
3
Task/String-append/Avail/string-append-1.avail
Normal file
3
Task/String-append/Avail/string-append-1.avail
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
str : string := "99 bottles of ";
|
||||
str ++= "beer";
|
||||
Print: str;
|
||||
7
Task/String-append/Avail/string-append-2.avail
Normal file
7
Task/String-append/Avail/string-append-2.avail
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Public method "_↑++=_" is
|
||||
[
|
||||
var : read tuple/write ⊥,
|
||||
t : tuple
|
||||
|
|
||||
var ?= eject var ++ t;
|
||||
] : ⊤;
|
||||
4
Task/String-append/Axe/string-append.axe
Normal file
4
Task/String-append/Axe/string-append.axe
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Lbl STRCAT
|
||||
Copy(r₂,r₁+length(r₁),length(r₂)+1)
|
||||
r₁
|
||||
Return
|
||||
6
Task/String-append/BASIC256/string-append.basic
Normal file
6
Task/String-append/BASIC256/string-append.basic
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
a$ = "He"
|
||||
a$ = a$ & "llo"
|
||||
a$ = a$ + " Wo"
|
||||
a$ += "rld"
|
||||
a$ &= "!"
|
||||
print a$
|
||||
4
Task/String-append/BBC-BASIC/string-append.basic
Normal file
4
Task/String-append/BBC-BASIC/string-append.basic
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
S$="Hello"
|
||||
S$+=" World!"
|
||||
PRINT S$
|
||||
END
|
||||
3
Task/String-append/BaCon/string-append.bacon
Normal file
3
Task/String-append/BaCon/string-append.bacon
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
A$ = "Hello"
|
||||
A$ = A$ & " World!"
|
||||
PRINT A$
|
||||
3
Task/String-append/Bracmat/string-append.bracmat
Normal file
3
Task/String-append/Bracmat/string-append.bracmat
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
str="Hello";
|
||||
str$(!str " World!"):?str;
|
||||
out$!str;
|
||||
9
Task/String-append/C++/string-append.cpp
Normal file
9
Task/String-append/C++/string-append.cpp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main( ) {
|
||||
std::string greeting( "Hello" ) ;
|
||||
greeting.append( " , world!" ) ;
|
||||
std::cout << greeting << std::endl ;
|
||||
return 0 ;
|
||||
}
|
||||
9
Task/String-append/C-sharp/string-append.cs
Normal file
9
Task/String-append/C-sharp/string-append.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string x = "foo";
|
||||
x += "bar";
|
||||
System.Console.WriteLine(x);
|
||||
}
|
||||
}
|
||||
25
Task/String-append/C/string-append.c
Normal file
25
Task/String-append/C/string-append.c
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char str[24]="Good Morning";
|
||||
char *cstr=" to all";
|
||||
char *cstr2=" !!!";
|
||||
int x=0;
|
||||
//failure when space allocated to str is insufficient.
|
||||
|
||||
if(sizeof(str)>strlen(str)+strlen(cstr)+strlen(cstr2))
|
||||
{
|
||||
/* 1st method*/
|
||||
strcat(str,cstr);
|
||||
|
||||
/*2nd method*/
|
||||
x=strlen(str);
|
||||
sprintf(&str[x],"%s",cstr2);
|
||||
|
||||
printf("%s\n",str);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
23
Task/String-append/COBOL/string-append.cobol
Normal file
23
Task/String-append/COBOL/string-append.cobol
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
identification division.
|
||||
program-id. string-append.
|
||||
|
||||
data division.
|
||||
working-storage section.
|
||||
01 some-string.
|
||||
05 elements pic x occurs 0 to 80 times depending on limiter.
|
||||
01 limiter usage index value 7.
|
||||
01 current usage index.
|
||||
|
||||
procedure division.
|
||||
append-main.
|
||||
|
||||
move "Hello, " to some-string
|
||||
|
||||
*> extend the limit and move using reference modification
|
||||
set current to length of some-string
|
||||
set limiter up by 5
|
||||
move "world" to some-string(current + 1:)
|
||||
display some-string
|
||||
|
||||
goback.
|
||||
end program string-append.
|
||||
8
Task/String-append/Clojure/string-append-1.clj
Normal file
8
Task/String-append/Clojure/string-append-1.clj
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
user=> (def s "app")
|
||||
#'user/s
|
||||
user=> s
|
||||
"app"
|
||||
user=> (def s (str s "end"))
|
||||
#'user/s
|
||||
user=> s
|
||||
"append"
|
||||
2
Task/String-append/Clojure/string-append-2.clj
Normal file
2
Task/String-append/Clojure/string-append-2.clj
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
user=> (let [s "ap", s (str s "pend")] s)
|
||||
"append"
|
||||
5
Task/String-append/CoffeeScript/string-append-1.coffee
Normal file
5
Task/String-append/CoffeeScript/string-append-1.coffee
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
a = "Hello, "
|
||||
b = "World!"
|
||||
c = a + b
|
||||
|
||||
console.log c
|
||||
1
Task/String-append/CoffeeScript/string-append-2.coffee
Normal file
1
Task/String-append/CoffeeScript/string-append-2.coffee
Normal file
|
|
@ -0,0 +1 @@
|
|||
console.log "Hello, ".concat "World!"
|
||||
4
Task/String-append/Commodore-BASIC/string-append.basic
Normal file
4
Task/String-append/Commodore-BASIC/string-append.basic
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
10 S$ = "HELLO"
|
||||
20 S$ = S$ + " WORLD!"
|
||||
30 PRINT S$
|
||||
40 END
|
||||
8
Task/String-append/Common-Lisp/string-append.lisp
Normal file
8
Task/String-append/Common-Lisp/string-append.lisp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(defmacro concatenatef (s &rest strs)
|
||||
"Append additional strings to the first string in-place."
|
||||
`(setf ,s (concatenate 'string ,s ,@strs)))
|
||||
(defvar *str* "foo")
|
||||
(concatenatef *str* "bar")
|
||||
(format T "~a~%" *str*)
|
||||
(concatenatef *str* "baz" "abc" "def")
|
||||
(format T "~a~%" *str*)
|
||||
7
Task/String-append/D/string-append.d
Normal file
7
Task/String-append/D/string-append.d
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import std.stdio;
|
||||
|
||||
void main() {
|
||||
string s = "Hello";
|
||||
s ~= " world!";
|
||||
writeln(s);
|
||||
}
|
||||
4
Task/String-append/DBL/string-append.dbl
Normal file
4
Task/String-append/DBL/string-append.dbl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
;Concatenate "Hello world!"
|
||||
STR='Hello'
|
||||
STR(%TRIM(STR)+2:5)='world'
|
||||
STR(%TRIM(STR)+1:1)='!'
|
||||
38
Task/String-append/Delphi/string-append.delphi
Normal file
38
Task/String-append/Delphi/string-append.delphi
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
program String_append;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses
|
||||
System.SysUtils;
|
||||
|
||||
type
|
||||
TStringHelper = record helper for string
|
||||
procedure Append(str: string);
|
||||
end;
|
||||
|
||||
{ TStringHelper }
|
||||
|
||||
procedure TStringHelper.Append(str: string);
|
||||
begin
|
||||
Self := self + str;
|
||||
end;
|
||||
|
||||
begin
|
||||
var h: string;
|
||||
|
||||
// with + operator
|
||||
h := 'Hello';
|
||||
h := h + ' World';
|
||||
writeln(h);
|
||||
|
||||
// with a function concat
|
||||
h := 'Hello';
|
||||
h := Concat(h, ' World');
|
||||
writeln(h);
|
||||
|
||||
// with helper
|
||||
h := 'Hello';
|
||||
h.Append(' World');
|
||||
writeln(h);
|
||||
readln;
|
||||
end.
|
||||
3
Task/String-append/Dyalect/string-append.dyalect
Normal file
3
Task/String-append/Dyalect/string-append.dyalect
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var str = "foo"
|
||||
str += str
|
||||
print(str)
|
||||
6
Task/String-append/EMal/string-append.emal
Normal file
6
Task/String-append/EMal/string-append.emal
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
^|EMal has mutable strings;
|
||||
|the append method changes the value in-place.
|
||||
|^
|
||||
text hello = "Hello, "
|
||||
hello.append("world!")
|
||||
writeLine(hello)
|
||||
3
Task/String-append/EasyLang/string-append.easy
Normal file
3
Task/String-append/EasyLang/string-append.easy
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
a$ = "hello"
|
||||
a$ &= " world"
|
||||
print a$
|
||||
9
Task/String-append/EchoLisp/string-append.l
Normal file
9
Task/String-append/EchoLisp/string-append.l
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
;; Solution from Common Lisp and Racket
|
||||
(define-syntax-rule (set-append! str tail)
|
||||
(set! str (string-append str tail)))
|
||||
|
||||
(define name "Albert") → name
|
||||
|
||||
(set-append! name " de Jeumont-Schneidre")
|
||||
name
|
||||
→ "Albert de Jeumont-Schneidre"
|
||||
10
Task/String-append/Elena/string-append.elena
Normal file
10
Task/String-append/Elena/string-append.elena
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import extensions;
|
||||
import extensions'text;
|
||||
|
||||
public program()
|
||||
{
|
||||
var s := StringWriter.load("Hello");
|
||||
s.append:" World";
|
||||
|
||||
console.printLine:s.readChar()
|
||||
}
|
||||
4
Task/String-append/Elixir/string-append.elixir
Normal file
4
Task/String-append/Elixir/string-append.elixir
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
iex(60)> s = "Hello"
|
||||
"Hello"
|
||||
iex(61)> s <> " World!"
|
||||
"Hello World!"
|
||||
3
Task/String-append/Emacs-Lisp/string-append-1.l
Normal file
3
Task/String-append/Emacs-Lisp/string-append-1.l
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(defvar str "foo")
|
||||
(setq str (concat str "bar"))
|
||||
str ;=> "foobar"
|
||||
5
Task/String-append/Emacs-Lisp/string-append-2.l
Normal file
5
Task/String-append/Emacs-Lisp/string-append-2.l
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(require 'cl-lib)
|
||||
|
||||
(defvar str "foo")
|
||||
(cl-callf concat str "bar")
|
||||
str ;=> "foobar"
|
||||
8
Task/String-append/Emacs-Lisp/string-append-3.l
Normal file
8
Task/String-append/Emacs-Lisp/string-append-3.l
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(let ((buf (get-buffer-create "*foo*")))
|
||||
(with-current-buffer buf
|
||||
(insert "foo"))
|
||||
(with-current-buffer buf
|
||||
(goto-char (point-max))
|
||||
(insert "bar")
|
||||
(buffer-string)))
|
||||
;; => "foobar"
|
||||
7
Task/String-append/Euphoria/string-append.euphoria
Normal file
7
Task/String-append/Euphoria/string-append.euphoria
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
sequence string = "String"
|
||||
|
||||
printf(1,"%s\n",{string})
|
||||
|
||||
string &= " is now longer\n"
|
||||
|
||||
printf(1,"%s",{string})
|
||||
3
Task/String-append/F-Sharp/string-append.fs
Normal file
3
Task/String-append/F-Sharp/string-append.fs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
let mutable x = "foo"
|
||||
x <- x + "bar"
|
||||
printfn "%s" x
|
||||
1
Task/String-append/Factor/string-append.factor
Normal file
1
Task/String-append/Factor/string-append.factor
Normal file
|
|
@ -0,0 +1 @@
|
|||
"Hello, " "world!" append
|
||||
6
Task/String-append/Falcon/string-append.falcon
Normal file
6
Task/String-append/Falcon/string-append.falcon
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/* Added by Aykayayciti Earl Lamont Montgomery
|
||||
April 10th, 2018 */
|
||||
|
||||
s1, s2 = "Hello", "Foo"
|
||||
> s1 + " World"
|
||||
printl(s2 + " bar")
|
||||
7
Task/String-append/Forth/string-append-1.fth
Normal file
7
Task/String-append/Forth/string-append-1.fth
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
\ Strings in Forth are simply named memory locations
|
||||
|
||||
create astring 256 allot \ create a "string"
|
||||
|
||||
s" Hello " astring PLACE \ initialize the string
|
||||
|
||||
s" World!" astring +PLACE \ append with "+place"
|
||||
4
Task/String-append/Forth/string-append-2.fth
Normal file
4
Task/String-append/Forth/string-append-2.fth
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ok
|
||||
s" Hello " astring place ok
|
||||
s" World!" astring +place ok
|
||||
astring count type Hello World! ok
|
||||
10
Task/String-append/Fortran/string-append-1.f
Normal file
10
Task/String-append/Fortran/string-append-1.f
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
program main
|
||||
|
||||
character(len=:),allocatable :: str
|
||||
|
||||
str = 'hello'
|
||||
str = str//' world'
|
||||
|
||||
write(*,*) str
|
||||
|
||||
end program main
|
||||
10
Task/String-append/Fortran/string-append-2.f
Normal file
10
Task/String-append/Fortran/string-append-2.f
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
program str_append
|
||||
implicit none
|
||||
|
||||
character(len=20) :: str
|
||||
|
||||
str= 'String'
|
||||
str(len_trim(str)+1:) = 'Append'
|
||||
print *, str
|
||||
|
||||
end program str_append
|
||||
6
Task/String-append/FreeBASIC/string-append.basic
Normal file
6
Task/String-append/FreeBASIC/string-append.basic
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Var s = "String"
|
||||
s += " append"
|
||||
Print s
|
||||
Sleep
|
||||
8
Task/String-append/GDScript/string-append.gd
Normal file
8
Task/String-append/GDScript/string-append.gd
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
extends MainLoop
|
||||
|
||||
|
||||
func _process(_delta: float) -> bool:
|
||||
var string: String = "123"
|
||||
string += "abc"
|
||||
print(string)
|
||||
return true # Exit
|
||||
7
Task/String-append/Gambas/string-append.gambas
Normal file
7
Task/String-append/Gambas/string-append.gambas
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Public Sub Main()
|
||||
Dim sString As String = "Hello "
|
||||
|
||||
sString &= "World!"
|
||||
Print sString
|
||||
|
||||
End
|
||||
7
Task/String-append/Genie/string-append.genie
Normal file
7
Task/String-append/Genie/string-append.genie
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[indent=4]
|
||||
/* String append, in Genie */
|
||||
init
|
||||
str:string = "Hello"
|
||||
str += ", world"
|
||||
|
||||
print str
|
||||
3
Task/String-append/GlovePIE/string-append.glovepie
Normal file
3
Task/String-append/GlovePIE/string-append.glovepie
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var.string="This is "
|
||||
var.string+="Sparta!"
|
||||
debug=var.string
|
||||
2
Task/String-append/Go/string-append-1.go
Normal file
2
Task/String-append/Go/string-append-1.go
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
s := "foo"
|
||||
s += "bar"
|
||||
13
Task/String-append/Go/string-append-2.go
Normal file
13
Task/String-append/Go/string-append-2.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var s strings.Builder
|
||||
s.WriteString("foo")
|
||||
s.WriteString("bar")
|
||||
fmt.Print(s.String())
|
||||
}
|
||||
14
Task/String-append/Gosu/string-append.gosu
Normal file
14
Task/String-append/Gosu/string-append.gosu
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Example 1
|
||||
var s = "a"
|
||||
s += "b"
|
||||
s += "c"
|
||||
print(s)
|
||||
|
||||
// Example 2
|
||||
print("a" + "b" + "c")
|
||||
|
||||
// Example 3
|
||||
var a = "a"
|
||||
var b = "b"
|
||||
var c = "c"
|
||||
print("${a}${b}${c}")
|
||||
8
Task/String-append/Groovy/string-append.groovy
Normal file
8
Task/String-append/Groovy/string-append.groovy
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
class Append{
|
||||
static void main(String[] args){
|
||||
def c="Hello ";
|
||||
def d="world";
|
||||
def e=c+d;
|
||||
println(e);
|
||||
}
|
||||
}
|
||||
1
Task/String-append/Haskell/string-append.hs
Normal file
1
Task/String-append/Haskell/string-append.hs
Normal file
|
|
@ -0,0 +1 @@
|
|||
main = putStrLn ("Hello" ++ "World")
|
||||
3
Task/String-append/IS-BASIC/string-append.basic
Normal file
3
Task/String-append/IS-BASIC/string-append.basic
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
100 LET S$="Hello"
|
||||
110 LET S$=S$&" World!"
|
||||
120 PRINT S$
|
||||
5
Task/String-append/Icon/string-append.icon
Normal file
5
Task/String-append/Icon/string-append.icon
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
procedure main()
|
||||
s := "foo"
|
||||
s ||:= "bar"
|
||||
write(s)
|
||||
end
|
||||
6
Task/String-append/J/string-append.j
Normal file
6
Task/String-append/J/string-append.j
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
s=: 'new'
|
||||
s
|
||||
new
|
||||
s=: s,' value' NB. append is in-place
|
||||
s
|
||||
new value
|
||||
1
Task/String-append/Java/string-append-1.java
Normal file
1
Task/String-append/Java/string-append-1.java
Normal file
|
|
@ -0,0 +1 @@
|
|||
String string = "abc" + "def";
|
||||
2
Task/String-append/Java/string-append-2.java
Normal file
2
Task/String-append/Java/string-append-2.java
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
String string = "abc";
|
||||
string += "def";
|
||||
1
Task/String-append/Java/string-append-3.java
Normal file
1
Task/String-append/Java/string-append-3.java
Normal file
|
|
@ -0,0 +1 @@
|
|||
String string = "abc".concat("def");
|
||||
2
Task/String-append/Java/string-append-4.java
Normal file
2
Task/String-append/Java/string-append-4.java
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
StringBuilder string = new StringBuilder();
|
||||
string.append("abc").append("def");
|
||||
3
Task/String-append/Java/string-append-5.java
Normal file
3
Task/String-append/Java/string-append-5.java
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
StringBuilder string = new StringBuilder();
|
||||
string.append("abc");
|
||||
string.insert(3, "def");
|
||||
1
Task/String-append/Java/string-append-6.java
Normal file
1
Task/String-append/Java/string-append-6.java
Normal file
|
|
@ -0,0 +1 @@
|
|||
String string = String.format("%s%s", "abc", "def");
|
||||
1
Task/String-append/Java/string-append-7.java
Normal file
1
Task/String-append/Java/string-append-7.java
Normal file
|
|
@ -0,0 +1 @@
|
|||
String string = "%s%s".formatted("abc", "def");
|
||||
8
Task/String-append/Java/string-append-8.java
Normal file
8
Task/String-append/Java/string-append-8.java
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
String sa = "Hello";
|
||||
sa += ", World!";
|
||||
System.out.println(sa);
|
||||
|
||||
StringBuilder ba = new StringBuilder();
|
||||
ba.append("Hello");
|
||||
ba.append(", World!");
|
||||
System.out.println(ba.toString());
|
||||
8
Task/String-append/JavaScript/string-append.js
Normal file
8
Task/String-append/JavaScript/string-append.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
var s1 = "Hello";
|
||||
s1 += ", World!";
|
||||
print(s1);
|
||||
|
||||
var s2 = "Goodbye";
|
||||
// concat() returns the strings together, but doesn't edit existing string
|
||||
// concat can also have multiple parameters
|
||||
print(s2.concat(", World!"));
|
||||
5
Task/String-append/Jq/string-append-1.jq
Normal file
5
Task/String-append/Jq/string-append-1.jq
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"Hello" | . += ", world!"
|
||||
|
||||
["Hello"] | .[0] += ", world!" | .[0]
|
||||
|
||||
{ "greeting": "Hello"} | .greeting += ", world!" | .greeting
|
||||
1
Task/String-append/Jq/string-append-2.jq
Normal file
1
Task/String-append/Jq/string-append-2.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
"Hello" as $a | $a | . += ", world!" as $a | $a
|
||||
13
Task/String-append/Jsish/string-append.jsish
Normal file
13
Task/String-append/Jsish/string-append.jsish
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* String append, in Jsish */
|
||||
var str = 'Hello';
|
||||
;str += ', world';
|
||||
|
||||
var s2 = 'Goodbye';
|
||||
;s2.concat(', World!');
|
||||
|
||||
/*
|
||||
=!EXPECTSTART!=
|
||||
str += ', world' ==> Hello, world
|
||||
s2.concat(', World!') ==> Goodbye, World!
|
||||
=!EXPECTEND!=
|
||||
*/
|
||||
2
Task/String-append/Julia/string-append.julia
Normal file
2
Task/String-append/Julia/string-append.julia
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
s = "Hello"
|
||||
s *= ", world!"
|
||||
4
Task/String-append/K/string-append.k
Normal file
4
Task/String-append/K/string-append.k
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
h: "hello "
|
||||
h,: "world"
|
||||
h
|
||||
"hello world"
|
||||
11
Task/String-append/Kotlin/string-append.kotlin
Normal file
11
Task/String-append/Kotlin/string-append.kotlin
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fun main(args: Array<String>) {
|
||||
var s = "a"
|
||||
s += "b"
|
||||
s += "c"
|
||||
println(s)
|
||||
println("a" + "b" + "c")
|
||||
val a = "a"
|
||||
val b = "b"
|
||||
val c = "c"
|
||||
println("$a$b$c")
|
||||
}
|
||||
7
Task/String-append/Lambdatalk/string-append.lambdatalk
Normal file
7
Task/String-append/Lambdatalk/string-append.lambdatalk
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{def christian_name Albert}
|
||||
-> christian_name
|
||||
{def name de Jeumont-Schneidre}
|
||||
-> name
|
||||
|
||||
{christian_name} {name}
|
||||
-> Albert de Jeumont-Schneidre
|
||||
4
Task/String-append/Lang/string-append.lang
Normal file
4
Task/String-append/Lang/string-append.lang
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$s = Hello
|
||||
$s += \, World!
|
||||
|
||||
fn.println($s)
|
||||
3
Task/String-append/Langur/string-append.langur
Normal file
3
Task/String-append/Langur/string-append.langur
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var .s = "no more "
|
||||
.s ~= "foo bars"
|
||||
writeln .s
|
||||
3
Task/String-append/Lasso/string-append.lasso
Normal file
3
Task/String-append/Lasso/string-append.lasso
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
local(x = 'Hello')
|
||||
#x->append(', World!')
|
||||
#x
|
||||
4
Task/String-append/Liberty-BASIC/string-append.basic
Normal file
4
Task/String-append/Liberty-BASIC/string-append.basic
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
a$ = "Hello"
|
||||
a$ = a$ + " World"
|
||||
a$ = a$ ; "!"
|
||||
print a$
|
||||
4
Task/String-append/Lingo/string-append.lingo
Normal file
4
Task/String-append/Lingo/string-append.lingo
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
str = "Hello"
|
||||
put " world!" after str
|
||||
put str
|
||||
-- "Hello world!"
|
||||
2
Task/String-append/LiveCode/string-append.livecode
Normal file
2
Task/String-append/LiveCode/string-append.livecode
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
local str="live"
|
||||
put "code" after str
|
||||
12
Task/String-append/Lua/string-append-1.lua
Normal file
12
Task/String-append/Lua/string-append-1.lua
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function string:show ()
|
||||
print(self)
|
||||
end
|
||||
|
||||
function string:append (s)
|
||||
self = self .. s
|
||||
end
|
||||
|
||||
x = "Hi "
|
||||
x:show()
|
||||
x:append("there!")
|
||||
x:show()
|
||||
3
Task/String-append/Lua/string-append-2.lua
Normal file
3
Task/String-append/Lua/string-append-2.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
x = "Hi "
|
||||
x = x .. "there!"
|
||||
print(x)
|
||||
12
Task/String-append/M2000-Interpreter/string-append.m2000
Normal file
12
Task/String-append/M2000-Interpreter/string-append.m2000
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
a="ok"
|
||||
a+="(one)"
|
||||
Print a
|
||||
|
||||
a$="ok"
|
||||
a$+="(one)"
|
||||
Print a$
|
||||
|
||||
Document b$
|
||||
b$="ok"
|
||||
b$="(one)"
|
||||
Print b$
|
||||
3
Task/String-append/Maple/string-append.maple
Normal file
3
Task/String-append/Maple/string-append.maple
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
a := "Hello";
|
||||
b := cat(a, " World");
|
||||
c := `||`(a, " World");
|
||||
4
Task/String-append/Mathematica/string-append.math
Normal file
4
Task/String-append/Mathematica/string-append.math
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(* mutable strings are not supported *)
|
||||
s1 = "testing";
|
||||
s1 = s1 <> " 123";
|
||||
s1
|
||||
3
Task/String-append/Min/string-append.min
Normal file
3
Task/String-append/Min/string-append.min
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(quote cons "" join) :str-append
|
||||
|
||||
"foo" "bar" str-append puts!
|
||||
1
Task/String-append/MontiLang/string-append-1.monti
Normal file
1
Task/String-append/MontiLang/string-append-1.monti
Normal file
|
|
@ -0,0 +1 @@
|
|||
|Hello | |world!| swap + print
|
||||
3
Task/String-append/MontiLang/string-append-2.monti
Normal file
3
Task/String-append/MontiLang/string-append-2.monti
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
|Hello | var hello .
|
||||
|world!| var world .
|
||||
world hello + print
|
||||
3
Task/String-append/NS-HUBASIC/string-append.basic
Normal file
3
Task/String-append/NS-HUBASIC/string-append.basic
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
10 S$ = "HELLO"
|
||||
20 S$ = S$ + " WORLD!"
|
||||
30 PRINT S$
|
||||
4
Task/String-append/Nanoquery/string-append.nanoquery
Normal file
4
Task/String-append/Nanoquery/string-append.nanoquery
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
s1 = "this is"
|
||||
s1 += " a test"
|
||||
|
||||
println s1
|
||||
7
Task/String-append/Neko/string-append.neko
Normal file
7
Task/String-append/Neko/string-append.neko
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
<doc><p>String append in Neko</pre></doc>
|
||||
**/
|
||||
|
||||
var str = "Hello"
|
||||
str += ", world"
|
||||
$print(str, "\n")
|
||||
3
Task/String-append/NetRexx/string-append.netrexx
Normal file
3
Task/String-append/NetRexx/string-append.netrexx
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
s_ = 'Hello'
|
||||
s_ = s_', world!'
|
||||
say s_
|
||||
7
Task/String-append/NewLISP/string-append.l
Normal file
7
Task/String-append/NewLISP/string-append.l
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(setq str "foo")
|
||||
|
||||
(push "bar" str -1)
|
||||
; or as an alternative introduced in v.10.1
|
||||
(extend str "bar")
|
||||
|
||||
(println str)
|
||||
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