String concatenation: Difference between revisions
Add Ecstasy example
(Added solution for Action!) |
(Add Ecstasy example) |
||
(39 intermediate revisions by 29 users not shown) | |||
Line 19:
{{trans|Python}}
<
print(s1‘ world’)
V s2 = s1‘ world’
print(s2)</
{{out}}
Line 32:
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
<syntaxhighlight lang="aarch64 assembly">
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program concatStr64.s */
Line 97:
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
</syntaxhighlight>
{{Output}}
<pre>
Line 104:
=={{header|ABAP}}==
<
s2 TYPE string.
Line 111:
WRITE: / s1.
WRITE: / s2.
</syntaxhighlight>
{{out}}
<pre>
Line 118:
</pre>
===Another way===
<
DATA(var1) = 'Hello'.
Line 131:
)->write( |{ var1 } world!|
)->display( ).
</syntaxhighlight>
{{out}}
<pre>
Line 139:
=={{header|Action!}}==
<
BYTE POINTER srcPtr,dstPtr
BYTE len
Line 169:
PROC Main()
TestConcatenate("Hello", " World!")
RETURN</
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/String_concatenation.png Screenshot from Atari 8-bit computer]
Line 177:
=={{header|ActionScript}}==
<
{
public class Str
Line 189:
}
}
}</
=={{header|Ada}}==
<
procedure String_Concatenation is
Line 200:
Put_Line (S1);
Put_Line (S2);
end String_Concatenation;</
{{out|Sample output}}
<pre>
Line 208:
=={{header|Aime}}==
<
s = "Hello";
o_(s, "\n");
v = s + ", World!";
o_(v, "\n");</
{{out}}
<pre>Hello
Line 222:
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny]}}
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d]}}
<
print ((s + " literal", new line));
STRING s1 := s + " literal";
print ((s1, new line))</
{{out}}
<pre>
Line 231:
hello literal
</pre>
=={{header|ALGOL-M}}==
<syntaxhighlight lang="algol">
begin
comment
The string concatenation operator is ||, and the
default string length is 10 characters unless a
longer length (up to 255) is explicitly declared;
string(20) s1, s2;
s1 := "Hello";
write (s1 || ", world");
s2 := s1 || ", world";
write (s2);
end
</syntaxhighlight>
{{out}}
<pre>
Hello, world
Hello, world
</pre>
=={{header|Apex}}==
<
String s1 = 'Hello ';
String s2 = 'Salesforce Developer!';
Line 241 ⟶ 268:
// Print output
System.debug(s3);</
{{out}}
<pre>Hello Salesforce Developer!</pre>
=={{header|AppleScript}}==
<
set endMsg to "world!"
set totMsg to "Hello, " & endMsg
display dialog totMsg
end try</
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
<syntaxhighlight lang="arm assembly">
/* ARM assembly Raspberry PI */
/* program strConcat.s */
Line 327 ⟶ 354:
bx lr @ return
</syntaxhighlight>
=={{header|Arturo}}==
<
str2: "World"
print str1 ++ str2 ++ "!"</
{{out}}
<pre>Hello World!</pre>
=={{header|Asymptote}}==
<syntaxhighlight lang="asymptote">string s1 = "Hello";
write(s1 + " World!");
write(s1, " World!");
string s2 = s1 + " World!";
write(s2);</syntaxhighlight>
=={{header|AutoHotkey}}==
<
Msgbox, %s%
s1 := s . " literal" ;the . is optional
Msgbox, %s1%</
=={{header|AWK}}==
The AWK concatenation operator is nothing.
<
s = "hello"
print s " literal"
s1 = s " literal"
print s1
}</
=={{header|Axe}}==
<
Copy(r₁,L₁,length(r₁))
Copy(r₂,L₁+length(r₁),length(r₂)+1)
L₁
Return</
=={{header|BASIC}}==
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
{{works with|BASIC256}}
{{works with|Liberty BASIC}}
{{works with|QB64}}
{{works with|Run Basic}}
{{works with|Yabasic}}
<syntaxhighlight lang="qbasic">s$ = "hello"
print s$ + " literal"
s2$ = s$ + " literal"
print s$
print s2$</
{{out}}
<pre>hello literal
Line 378 ⟶ 417:
A semicolon (;) is ''not'' the same as a concatenate operator (+), it is an instruction that works only on the <code>PRINT</code> statement to suppress newlines at the end of a literal or series of literals. For example, the instruction <code>S$="HELLO";"LITERAL"</code> would result in a syntax error.
<
20 PRINT S$ + " LITERAL"
30 PRINT S$
40 S2$ = S$ + " LITERAL"
50 PRINT S2$</
{{out}}
Line 390 ⟶ 429:
==={{header|BaCon}}===
<
A$ = "hello"
PRINT A$," World"
Line 396 ⟶ 435:
A2$ = A$ & " using & to concat World"
PRINT A2$
</syntaxhighlight>
==={{header|BBC BASIC}}===
<
stringvar2$ = stringvar1$ + " world!"
PRINT "Variable 1 is """ stringvar1$ """"
PRINT "Variable 2 is """ stringvar2$ """"</
{{out}}
<pre>Variable 1 is "Hello,"
Line 408 ⟶ 447:
==={{header|IS-BASIC}}===
<
110 LET S$=S$&" world!"
120 PRINT S$</
==={{header|BASIC256}}===
<syntaxhighlight lang="freebasic">s1$ = "Hello"
print s1$; " World!"
print s1$ + " World!"
print s1$ & " World!"
s2$ = s1$; " World!"
print s2$
s2$ = s1$ + " World!"
print s2$
s2$ = s1$ & " World!"
print s2$</syntaxhighlight>
==={{header|Run BASIC}}===
{{works with|Liberty BASIC}}
<syntaxhighlight lang="runbasic">s1$ = "Hello"
print s1$; " World!"
print s1$ + " World!"
s2$ = s1$; " World!"
print s2$
s2$ = s1$ + " World!"
print s2$</syntaxhighlight>
==={{header|True BASIC}}===
{{works with|BASIC256}}
<syntaxhighlight lang="qbasic">LET s1$ = "Hello"
PRINT s1$; " World!"
PRINT s1$ + " World!"
LET s2$ = s1$ & " World!"
PRINT s2$
END</syntaxhighlight>
==={{header|uBasic/4tH}}===
<syntaxhighlight lang="text">s = Dup("Hello")
Print Show(s); " World!"
Print Show(Join(s, " World!"))
t = Join(s, " World!")
Print Show(t)
End</syntaxhighlight>
==={{header|Yabasic}}===
{{works with|Liberty BASIC}}
{{works with|QB64}}
{{works with|QBasic}}
{{works with|Run BASIC}}
<syntaxhighlight lang="yabasic">s1$ = "Hello"
print s1$, " World!"
print s1$ + " World!"
s2$ = s1$ + " World!"
print s2$</syntaxhighlight>
==={{header|ZX Spectrum Basic}}===
<
20 LET s$=s$+" World!"
30 PRINT s$</
=={{header|Batch File}}==
<
echo %string% World
set string2=%string% World
echo %string2%</
=={{header|Beef}}==
<syntaxhighlight lang="csharp">using System;
namespace StringConcatenation
{
class Program {
static void Main() {
String s = scope ("hello");
Console.Write(s);
Console.WriteLine(" literal");
s.Append(" literal");
Console.WriteLine(s);
}
}
}
</syntaxhighlight>
=={{header|BQN}}==
<code>∾</code>(Join) will concatenate two strings together.
<syntaxhighlight lang="bqn">str ← "Hello "
newstr ← str ∾ "world"
•Show newstr</syntaxhighlight>
<syntaxhighlight lang="bqn">"Hello world"</syntaxhighlight>
=={{header|Bracmat}}==
<
& "World":?var2
& str$(!var1 !var2):?var12
& put$("var1=" !var1 ", var2=" !var2 ", var12=" !var12 "\n")</
{{out}}
<pre>var1= Hello , var2= World , var12= Hello World</pre>
=={{header|Burlesque}}==
<
"Hello, world!"</
=={{header|C}}==
<
#include <stdlib.h>
#include <string.h>
Line 460 ⟶ 572:
puts(s2);
free(s2);
}</
=={{header|C sharp|C#}}==
<
class Program {
Line 473 ⟶ 585:
Console.WriteLine(s2);
}
}</
=={{header|C++}}==
<
#include <iostream>
Line 485 ⟶ 597:
std::cout << s2 << std::endl;
return 0;
}</
{{out}}
<pre>hello literal
Line 491 ⟶ 603:
=={{header|ChucK}}==
<syntaxhighlight lang="text">
"Hello" => string A;
A + " World!" => string B;
<<< B >>>;
</syntaxhighlight>
{{out}}
<pre>"Hello World!"</pre>
=={{header|Clojure}}==
<
(println (str a-str "efgh"))
(def a-new-str (str a-str "efgh"))
(println a-new-str)</
=={{header|COBOL}}==
With the <code>STRING</code> verb:
<
PROGRAM-ID. Concat.
Line 522 ⟶ 634:
GOBACK
.</
Alternate method using the <code>CONCATENATE</code> intrinsic function:
<
PROCEDURE DIVISION.
DISPLAY "Str : " Str
Line 531 ⟶ 643:
GOBACK
.</
String literals can also be concatenated in the follwing ways:
<
01 Long-Str-Val PIC X(200) VALUE "Lorem ipsum dolor sit "
& "amet, consectetuer adipiscing elit, sed diam nonummy "
Line 544 ⟶ 656:
01 Another-Long-Str PIC X(200) VALUE " Ut wisi enim ad minim
- "veniam, quis nostrud exerci tation ullamcorper suscipit
- "lobortis nisl ut aliquip ex ea commodo consequat".</
=={{header|Common Lisp}}==
<
(format t "~a there!~%" s)
(let* ((s2 " there!")
(s (concatenate 'string s s2)))
(format t "~a~%" s)))</
<
(print (concatenate 'string *s* " literal"))
(defparameter *s1* (concatenate 'string *s* " literal"))
(print *s1*)</
=={{header|Component Pascal}}==
BlackBox Component Builder
<
MODULE StringConcatenation;
IMPORT StdLog;
Line 573 ⟶ 685:
END StringConcatenation.
</syntaxhighlight>
Execute: ^Q StringConcatenation.Do<br/>
{{out}}
Line 581 ⟶ 693:
=={{header|D}}==
<
void main() {
Line 588 ⟶ 700:
auto s2 = s ~ " world";
writeln(s2);
}</
=={{header|DCL}}==
<
$ string2 = string1 + " world"
$ show symbol string*</
{{out}}
<pre> STRING1 = "hello"
Line 599 ⟶ 711:
=={{header|Delphi}}==
<
{$APPTYPE CONSOLE}
Line 610 ⟶ 722:
WriteLn(s1);
WriteLn(s2);
end.</
=={{header|DWScript}}==
<
var s2 := s1 + ' World';
PrintLn(s1);
PrintLn(s2);</
=={{header|Dyalect}}==
Line 623 ⟶ 735:
{{trans|Swift}}
<
print(s + " literal")
var s1 = s + " literal"
print(s1)</
=={{header|Dylan.NET}}==
<syntaxhighlight lang="dylan.net">
//to be compiled using dylan.NET v. 11.5.1.2 or later.
#refstdasm mscorlib.dll
Line 648 ⟶ 760:
end method
end class</
=={{header|Déjà Vu}}==
<
local :s2 concat( s1 ", world" )
!print s2</
{{out}}
<pre>hello, world</pre>
=={{header|EasyLang}}==
<syntaxhighlight lang="text">a$ = "hello"
b$ = a$ & " world"
print b$</
=={{header|Ecstasy}}==
<syntaxhighlight lang="ecstasy">
module StringAppend {
void run() {
String start = "hello";
String finish = " world";
// approach #1: add strings together
String approach1 = start + finish;
// approach #2: StringBuffer
String approach2 = new StringBuffer()
.append(start)
.append(finish)
.toString();
// approach #3: string template
String approach3 = $"{start}{finish}";
@Inject Console console;
console.print($|
|Appending strings:
|
| {start=}
| {finish=}
|
| {approach1=}
| {approach2=}
| {approach3=}
|
);
}
}
</syntaxhighlight>
{{out}}
<pre>
x$ xec doc/examples/StringAppend
Appending strings:
start=hello
finish= world
approach1=hello world
approach2=hello world
approach3=hello world
</pre>
=={{header|Ela}}==
Strings in Ela support a polymorphic concatenation operator (++):
<
hello'world = hello ++ ", " ++ "world"
(hello, hello'world)</
{{out}}
<pre>("Hello", "Hello, world!")</pre>
Line 672 ⟶ 833:
a large number of concatenations. Therefore one can use an alternate technique (a pure StringBuilder
type defined in standard prelude). The resulting code would look like so:
<
The (+>) token is a type constructor. Therefore the result of its application is an instance of type
StringBuilder. In order to produce a string one should call a polymorphic toString function at the end
Line 678 ⟶ 839:
=={{header|Elena}}==
ELENA
<
{
var s := "Hello";
var s2 := s + " literal";
console.writeLine
console.writeLine
console.readChar()
}</
{{out}}
<pre>
Hello
Hello literal
</pre>
=={{header|EMal}}==
<syntaxhighlight lang="emal">
text s = "hello"
write(s)
writeLine(" literal")
text s2 = s + " literal"
writeLine(s2)
</syntaxhighlight>
{{out}}
<pre>
hello literal
hello literal
</pre>
=={{header|Elixir}}==
<
s = "hello"
t = s <> " literal"
Line 701 ⟶ 876:
IO.puts s
IO.puts t
</syntaxhighlight>
{{out}}
<pre>
Line 709 ⟶ 884:
=={{header|Emacs Lisp}}==
<syntaxhighlight lang="lisp">(defvar foo "foo")
(defvar foobar (concat foo "bar"))
(message "%sbar" foo)
(message "%s" foobar)</syntaxhighlight>
{{out}}
foobar
foobar
=={{header|Erlang}}==
<
S1 = S ++ " literal",
io:format ("~s literal~n",[S]),
io:format ("~s~n",[S1])</
{{out|Sample output}}
<pre>
Line 742 ⟶ 907:
=={{header|ERRE}}==
<syntaxhighlight lang="erre">
..........
S$="HELLO"
Line 749 ⟶ 914:
PRINT(S2$)
..........
</syntaxhighlight>
=={{header|Euphoria}}==
<
s = "hello"
puts(1, s & " literal")
Line 758 ⟶ 923:
s1 = s & " literal"
print (1, s1))
puts(1,'\n')</
{{out}}
hello literal
Line 766 ⟶ 931:
Take three cells, say A1,B1 and C1. In C1, type in :
<
=CONCATENATE(A1;" ";B1)
</syntaxhighlight>
As the text in A1 and/or B1 is changed, C1 will be updated.
<syntaxhighlight lang="text">
Hello World Hello World
</syntaxhighlight>
=={{header|F_Sharp|F#}}==
{{trans|C#}}
<
[<EntryPoint>]
Line 789 ⟶ 954:
let s2 = s + " literal"
Console.WriteLine(s2)
0</
=={{header|Factor}}==
<
=={{header|Falcon}}==
'''VBA/Python programmer's approach. I'm just a junior Falconeer but this code seems falconic''
<
/* created by Aykayayciti Earl Lamont Montgomery
April 9th, 2018 */
Line 804 ⟶ 969:
s2 = s + " literal"
> s2
</syntaxhighlight>
{{out}}
<pre>
Line 814 ⟶ 979:
=={{header|Fantom}}==
Illustrating in <tt>fansh</tt>:
<
abc
fansh> b := a + "def"
Line 821 ⟶ 986:
abc
fansh> b
abcdef</
<syntaxhighlight lang="java">
/* gary chike 08/27/2023 */
class Main
{
static Void main() {
s1 := "Only The"
s2 := "knows"
s3 := s1 + " Fantom " + s2 + "!" // Concatenation
echo(s3)
s4 := "$s1 Fantom $s2!" // String interpolation
echo(s4)
}
}
</syntaxhighlight>
{{out}}
<pre>
Only The Fantom knows!
Only The Fantom knows!
</pre>
=={{header|Fe}}==
'''pack''' is not a built-in function, see its definition [[Reverse_a_string#Fe|here]].
<syntaxhighlight lang="clojure">
(print (pack '("Hello" " world!")))
</syntaxhighlight>
=={{header|Forth}}==
{{works with|GNU Forth}}
<
pad count type
s" there!" pad +place \ +place is called "append" on some Forths
pad count type</
=={{header|Fortran}}==
<
integer, parameter :: maxstringlength = 64
Line 840 ⟶ 1,033:
print *,s1
end program</
=={{header|FreeBASIC}}==
<
Var s1 = "String"
Line 849 ⟶ 1,042:
Print s1
Print s2
Sleep</
{{out}}
Line 858 ⟶ 1,051:
=={{header|Frink}}==
<
a = "Frink"
b = a + " rules!"
println[b]
</syntaxhighlight>
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">window 1
CFStringRef s1, s2
s1 = @"any text value "
print s1
s2 = fn StringByAppendingString( s1, @"another string literal" )
print s2
HandleEvents</syntaxhighlight>
=={{header|Gambas}}==
Line 868 ⟶ 1,074:
'''[https://gambas-playground.proko.eu/?gist=098450adbbe0e284f0b9cdac67d74dda Click this link to run this code]'''
<
DIM bestclub AS String
DIM myconcat AS String
Line 877 ⟶ 1,083:
Print myconcat
End</
=={{header|GDScript}}==
{{works with|Godot|4.0.1}}
<syntaxhighlight lang="gdscript">
extends MainLoop
func _process(_delta: float) -> bool:
var first: String = "123"
var second: String = first + "abc"
print(first)
print(second)
return true # Exit
</syntaxhighlight>
=={{header|GlovePIE}}==
<
debug=var.text1+"world!"</
=={{header|Go}}==
<
import "fmt"
Line 904 ⟶ 1,127:
// output second string variable
fmt.Println(s2)
}</
{{out}}
<pre>
Line 913 ⟶ 1,136:
=={{header|Golfscript}}==
<
s"Earthlings"+puts
s"Earthlings"+:s1;
s1 puts</
=={{header|Groovy}}==
<
println s + "Earthlings"
def s1 = s + "Earthlings"
println s1</
{{out}}
<pre>Greetings Earthlings
Line 930 ⟶ 1,153:
=={{header|Halon}}==
The dot (concatenation) operator may cast datatypes to strings.
<
=={{header|Haskell}}==
<
s = "hello"
s1 = s ++ " literal"
main = do putStrLn (s ++ " literal")
putStrLn s1</
=={{header|HicEst}}==
<
WRITE() s // " literal"
sl = s // " literal"
WRITE() sl</
=={{header|Icon}} and {{header|Unicon}}==
<
s1 := "hello"
write(s2 := s1 || " there.") # capture the reuslt for
write(s2) # ... the 2nd write
end</
=={{header|IDL}}==
<
print, s1 + ' literal'
s2=s1 + ' literal'
print, s2</
=={{header|J}}==
<
]s1, 'text '
Some text
]s2 =. s1 , 'more text!'
Some more text!</
For more info see:
* http://www.jsoftware.com/help/dictionary/d320.htm on <code>,</code>
Line 970 ⟶ 1,193:
=={{header|Java}}==
There are multiple ways to concatenate string values in Java.<br />
The most common way is through the plus operator.
<syntaxhighlight lang="java">
String string = "abc" + "def";
</syntaxhighlight>
Which can also be written as
<syntaxhighlight lang="java">
String string = "abc";
string += "def";
</syntaxhighlight>
There is also the ''String.concat'' method
<syntaxhighlight lang="java">
String string = "abc".concat("def");
</syntaxhighlight>
You could use a ''StringBuilder'' object if you're appending multiple strings.
<syntaxhighlight lang="java">
StringBuilder string = new StringBuilder();
string.append("abc").append("def");
</syntaxhighlight>
''StringBuilder'' also conveniently lets you insert strings within strings.<br />
So, you can also concatenate a string as follows
<syntaxhighlight lang="java">
StringBuilder string = new StringBuilder();
string.append("abc");
string.insert(3, "def");
</syntaxhighlight>
A less common approach would be to use the ''String.format'' or ''String.formatted'' methods.
<syntaxhighlight lang="java">
String string = String.format("%s%s", "abc", "def");
</syntaxhighlight>
<syntaxhighlight lang="java">
String string = "%s%s".formatted("abc", "def");
</syntaxhighlight>
All of these methods will produce the following string
<pre>
abcdef
</pre>
<br />
Alternately
<syntaxhighlight lang="java5">public class Str{
public static void main(String[] args){
String s = "hello";
Line 977 ⟶ 1,239:
System.out.println(s2);
}
}</
{{out}}
<pre>hello literal
Line 983 ⟶ 1,245:
=={{header|JavaScript}}==
<
print(s + " there!")</
=={{header|Joy}}==
<syntaxhighlight lang="joy">
"title:" " text" concat.</syntaxhighlight>
{{out}}
<pre>"title: text"</pre>
=={{header|jq}}==
<
{{Out}}
# Use the -r command-line option if you wish
Line 994 ⟶ 1,262:
=={{header|Julia}}==
<
println(s * " there!")</
=={{header|K}}==
Translation of <b>J</b> code:
<syntaxhighlight lang="k">
s1: "Some "
s1, "text "
s2: s1 , "more text!"
</syntaxhighlight>
{{out}}
<pre>
Line 1,012 ⟶ 1,280:
=={{header|Kotlin}}==
<syntaxhighlight lang
val s1 = "James"
val s2 = "Bond"
Line 1,019 ⟶ 1,287:
val s3 = s1 + " " + s2
println(s3)
}</
{{Out}}
<pre>James
Line 1,034 ⟶ 1,302:
=={{header|Lambdatalk}}==
In Lambdatalk writing {def name a sequence of words} replaces the sequence of words by the given name in the code string. The name is a word and is not evaluated. Bracketing a name between two curly braces returns its related value. And concatenating named strings is simply done by writing names between curly braces and separated by spaces.
<syntaxhighlight lang="scheme">
{def christian_name Albert}
-> christian_name
Line 1,042 ⟶ 1,310:
{christian_name} {name}
-> Albert de Jeumont-Schneidre
</syntaxhighlight>
=={{header|Lang}}==
<syntaxhighlight lang="lang">
$s1 = hello
$s2 = \sworld
fn.println($s1 world)
# Output: hello world
fn.println($s1$s2)
# Output: hello world
fn.println(fn.concat($s1, $s2))
# Output: hello world
fn.println(parser.op($s1 ||| $s2))
# Output: hello world
fn.println(fn.add($s1, $s2))
# Output: hello world
fn.println(parser.op($s1 + $s2))
# Output: hello world
</syntaxhighlight>
=={{header|Lang5}}==
<
'hello " literal" concat</
=={{header|Lasso}}==
<
local(y = #x + ', World!')
#x // Hello
#y // Hello, World!</
=={{header|Liberty BASIC}}==
Line 1,058 ⟶ 1,350:
=={{header|Lingo}}==
<
b = a & " world!"
put b
-- "Hello world!"</
=={{header|Lisaac}}==
<
+ name := STRING_CONCATENATION;
Line 1,080 ⟶ 1,372:
sv.println;
);</
=={{header|LiveCode}}==
<
put str & "code" into str2
put str && str2</
Output<pre>live livecode</pre>
=={{header|Logo}}==
<
print word :s "| there!|</
=={{header|Lua}}==
<
print(a .. "world")
c = a .. "world"
print(c)</
=={{header|M2000 Interpreter}}==
Line 1,103 ⟶ 1,395:
A memory word is two bytes.
<syntaxhighlight lang="m2000 interpreter">
Module CheckString {
s$ = "hello"
Line 1,120 ⟶ 1,412:
}
CheckString
</syntaxhighlight>
=={{header|M4}}==
M4 has macros rather than variables, but a macro expanded can work like a variable.
<
define(`A',`any text value')dnl
concat(`A',` concatenated with string literal')
define(`B',`concat(`A',` and string literal')')dnl
B</
=={{header|Maple}}==
<
newstr := cat(str,", world!"):
str;
newstr;</
{{out}}
<pre>
Line 1,159 ⟶ 1,451:
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<
str<>"Literal"</
=={{header|MATLAB}} / {{header|Octave}}==
<
string1 =
Line 1,173 ⟶ 1,465:
string2 =
1 Fish, 2 Fish, Red Fish, Blue Fish</
=={{header|Maxima}}==
<
t: "jumps over the lazy dog";
sconcat(s, " ", t);
/* "the quick brown fox jumps over the lazy dog" */</
=={{header|MAXScript}}==
<
print (s + " literal")
s1 = s + " literal"
print s1</
=={{header|Mercury}}==
<
:- interface.
Line 1,201 ⟶ 1,493:
S1 = S ++ " world",
io.write_string(S, !IO), io.nl(!IO),
io.write_string(S1, !IO), io.nl(!IO).</
=={{header|Metafont}}==
<
a := "String";
message a & " literal";
b := a & " literal";
message b;</
=={{header|min}}==
{{works with|min|0.19.3}}
<
(a "scotch")=> "" join :b
a puts!
b puts!</
{{out}}
<pre>
Line 1,223 ⟶ 1,515:
=={{header|MiniScript}}==
<
print s + " world!"</
{{output}}
<pre>hello world!</pre>
=={{header|MIPS Assembly}}==
Using the following implementation of [[C]]'s <code>strcpy()</code>, we can concatenate strings easily by copying them to a RAM buffer back-to-back. We'll only do a few so that we don't clobber any other RAM we're using.
<syntaxhighlight lang="mips">main:
la $a0,String1
la $a1,UserRam
jal strcpy
nop
la $a0,String2
jal strcpy
nop
la $a0,UserRam
jal PrintString
nop
shutdown:
nop ;normally not needed, but Project 64 will throw an exception if I don't have a nop here.
b shutdown ;loop forever
nop
strcpy:
LBU t0,(a0)
nop
beqz t0,strcpy_done
SB t0,(a1) ;branch delay slot - this is actually executed BEFORE the beqz!
addiu a0,a0,1
b strcpy
addiu a1,a1,1 ;branch delay slot
strcpy_done:
jr ra
nop
String1:
.ascii "abcdefghijk"
.byte 0
.align 4
String2:
.ascii "lmnopqrstuvwxyz"
.byte 0
.align 4</syntaxhighlight>
{{out}}
<pre>abcdefghijklmnopqrstuvwxyz</pre>
=={{header|Modula-3}}==
Strings in Modula-3 are called <code>TEXT</code>s. Concatenation can use <code>&</code>, just like [[Ada]].
<
IMPORT IO;
Line 1,242 ⟶ 1,579:
string1 := string & " literal.\n";
IO.Put(string1);
END Concat.</
Modula-3 also provides modules for dealing with <code>TEXT</code>s, such as <code>Text</code>.
<
=={{header|MUMPS}}==
<
SET S="STRING"
WRITE !,S
SET T=S_" LITERAL"
WRITE !,T
QUIT</
{{out}}
<pre>
Line 1,262 ⟶ 1,599:
=={{header|Nanoquery}}==
<
println s1 + " world"
s2 = s1 + " world"
println s2</
{{out}}
<pre>hello world
Line 1,272 ⟶ 1,609:
=={{header|Neko}}==
<syntaxhighlight lang="actionscript">/**
String concatenation, in Neko
Tectonics:
Line 1,293 ⟶ 1,630:
$print("addon: ", addon, "\n")
$print("c: ", c, "\n")
}</
{{out}}
Line 1,305 ⟶ 1,642:
=={{header|Nemerle}}==
Can be done with Concat() method or + operator:
<
using System.Console;
using Nemerle.Utility.NString; // contains method Concat()
Line 1,318 ⟶ 1,655:
Write($"$cat1\n$cat2\n");
}
}</
=={{header|NetRexx}}==
<
options replace format comments java crossref savelog symbols
Line 1,340 ⟶ 1,677:
say 's6:' s6
say 's7:' s7
</syntaxhighlight>
{{out}}
<pre>
Line 1,352 ⟶ 1,689:
=={{header|NewLISP}}==
<
(println str1)
(let (str2 (string str1 "bar"))
(println str2)))</
=={{header|Nim}}==
Strings can be concatenated with <code>&</code>.
<
echo str & " literal."
# -> String literal.</
Strings can be concatenated as arrays and joined with separating characters:
<
var str = "String"
echo join([str, " literal.", "HelloWorld!"], "~~")
# -> String~~ literal.~~HelloWorld!</
Strings can be combined using string formatting:
<
var str = "String"
Line 1,380 ⟶ 1,717:
# Alternate form providing automatic conversion of arguments to strings.
echo "$# $# $#".format(str, 123, "HelloWorld!")
# -> String 123 HelloWorld!</
=={{header|NS-HUBASIC}}==
<
20 STRING$=STRING$+" WORLD!"
30 PRINT STRING$</
=={{header|Objeck}}==
<
class Repeat {
function : Main(args : String[]) ~ Nil {
Line 1,398 ⟶ 1,735:
}
}
}</
=={{header|Oberon-2}}==
<syntaxhighlight lang="oberon2">MODULE Concat;
IMPORT Out,Strings;
VAR
S1:ARRAY 16 OF CHAR;
S2:ARRAY 8 OF CHAR;
PS1,PS2:POINTER TO ARRAY OF CHAR;
BEGIN
(* Static *)
S1 := "Hello ";
S2 := "literal";
Strings.Append(S2, S1);
Out.String(S1); Out.Ln;
(* Dynamic *)
NEW(PS1, 16);
NEW(PS2, 8);
COPY("Hello ", PS1^);
COPY("literal", PS2^);
Strings.Append(PS2^, PS1^);
Out.String(PS1^); Out.Ln;
END Concat.
</syntaxhighlight>
=={{header|Objective-C}}==
<
int main()
Line 1,420 ⟶ 1,782:
}
return 0;
}</
=={{header|OCaml}}==
<
let s1 = s ^ " literal"
let () =
print_endline (s ^ " literal");
print_endline s1</
=={{header|Oforth}}==
.s show the stack :
<
{{out}}
Line 1,441 ⟶ 1,803:
=={{header|Openscad}}==
<
b="berry";
c=str(a,b); /* Concatenate a and b */
echo (c);</
=={{header|Oz}}==
Strings are lists and are concatenated with the "Append" function. However, often "virtual strings" are used instead. [http://www.mozart-oz.org/home/doc/base/virtualstring.html "Virtual string are designed as a convenient way to combine strings, byte strings, atoms, integers and floats to compound strings without explicit concatenation and conversion"].
<
S = "hello"
{System.showInfo S#" literal"} %% virtual strings are constructed with "#"
S1 = {Append S " literal"}
{System.showInfo S1}</
=={{header|PARI/GP}}==
<
s = Str(s, "world");
\\ Alternately, this could have been:
\\ s = concat(s, "world");
print(s);</
=={{header|Pascal}}==
<
Var
s, s1 : String;
Line 1,472 ⟶ 1,834:
{ s1 := s + ' literal'; works too, with FreePascal }
writeln(s1);
End.</
=={{header|Perl}}==
<
print $s . ' literal', "\n";
my $s1 = $s . ' literal';
print $s1, "\n";</
An example of destructive concatenation:
<
print $s, "\n";</
=={{header|Phix}}==
{{libheader|Phix/basics}}
<!--<
<span style="color: #004080;">string</span> <span style="color: #000000;">s1</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"at"</span> <span style="color: #0000FF;">?</span><span style="color: #000000;">s1</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">s2</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"c"</span><span style="color: #0000FF;">&</span><span style="color: #000000;">s1</span> <span style="color: #0000FF;">?</span><span style="color: #000000;">s2</span>
Line 1,491 ⟶ 1,853:
<span style="color: #004080;">string</span> <span style="color: #000000;">s4</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"m"</span><span style="color: #0000FF;">&</span><span style="color: #000000;">s1</span> <span style="color: #0000FF;">?</span><span style="color: #000000;">s4</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">s5</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"The "</span><span style="color: #0000FF;">&</span><span style="color: #000000;">s2</span><span style="color: #0000FF;">&</span><span style="color: #008000;">" "</span><span style="color: #0000FF;">&</span><span style="color: #000000;">s3</span><span style="color: #0000FF;">&</span><span style="color: #008000;">" on the "</span><span style="color: #0000FF;">&</span><span style="color: #000000;">s4</span><span style="color: #0000FF;">&</span><span style="color: #008000;">"."</span> <span style="color: #0000FF;">?</span><span style="color: #000000;">s5</span>
<!--</
{{out}}
<pre>
Line 1,500 ⟶ 1,862:
"The cat sat on the mat."
</pre>
=={{header|Phixmonti}}==
<syntaxhighlight lang="Phixmonti">/# Rosetta Code problem: https://rosettacode.org/wiki/String_concatenation
by Galileo, 11/2022 #/
"Hello" " world" chain print nl
"Hello" var a
"world" var b
a print nl
b print nl
a " " b chain chain print
</syntaxhighlight>
{{out}}
<pre>Hello world
Hello
world
Hello world
=== Press any key to exit ===</pre>
=={{header|PHL}}==
<syntaxhighlight lang="text">module stringcat;
extern printf;
Line 1,513 ⟶ 1,894:
return 0;
]</
=={{header|PHP}}==
<
$s = "hello";
echo $s . " literal" . "\n";
$s1 = $s . " literal";
echo $s1 . "\n";
?></
=={{header|Picat}}==
<syntaxhighlight lang="picat">main =>
Hello = "Hello, ",
print(Hello ++ "world!" ++ "\n"),
String = Hello ++ "world!",
String := String ++ "\n",
print(String).</syntaxhighlight>
=={{header|PicoLisp}}==
<
(prinl Str1 " literal")
(let Str2 (pack Str1 " literal")
(prinl Str2) ) )</
=={{header|Pike}}==
<syntaxhighlight lang="pike">
string hello = "hello ";
write(hello + "world" + "\n");
string all_of_it = hello + "world";
write(all_of_it + "\n");
</syntaxhighlight>
{{Out}}
<pre>
Line 1,543 ⟶ 1,932:
=={{header|PL/I}}==
<
s = 'hello from me';
display (s || ' to you.' );
t = s || ' to you all';
display (t);</
=={{header|Plain English}}==
Strings (and other values) can be concatenated to strings with <code>then</code>.
<
Start up.
Put "hello" into a string.
Line 1,559 ⟶ 1,948:
Write the other string to the console.
Wait for the escape key.
Shut down.</
{{out}}
<pre>
Line 1,567 ⟶ 1,956:
=={{header|PowerShell}}==
<
Write-Host $s World.
Line 1,574 ⟶ 1,963:
$s2 = $s + " World."
Write-Host $s2</
=={{header|PureBasic}}==
<syntaxhighlight lang="basic">
If OpenConsole()
s$ = "hello"
PrintN( s$ + " literal")
Line 1,587 ⟶ 1,976:
Input()
CloseConsole()
EndIf</
{{out}}
<pre>
hello literal
hello literal
</pre>
This version uses the debugger versus outputting to the console. It
implements 'EnableExplicit' which is similar to VisuaBasic's 'Option Explicit' which means all variables must be declared. It also features the use of string variables WITHOUT the dollar-sign suffix '$' which is common in BASIC variants to indicate the string datatype:
<syntaxhighlight lang="basic">
EnableExplicit
Define.s s1, s2, s3
s1 = "Hello "
s2 = "World"
s3 = s1 + s2
Debug s3
s3 = s3 + "!"
Debug s3
</syntaxhighlight>
{{out}}
<pre>
Hello World
Hello World!
</pre>
=={{header|Python}}==
<
print s1 + " world"
s2 = s1 + " world"
print s2</
{{out}}
<pre>hello world
hello world</pre>
When concatenating many strings, it is more efficient to use the join method of a string object, which takes a list of strings to be joined. The string on which join is called is used as a separator.
<
print ", ".join([s1, "world", "mom"])
s2 = ", ".join([s1, "world", "mom"])
print s2</
{{out}}
<pre>hello, world, mom
Line 1,609 ⟶ 2,025:
=={{header|QB64}}==
<
s2$ = s1$ + " concatenation"
Print s1$
Print s2$</
{{out}}
<pre>
Line 1,621 ⟶ 2,037:
=={{header|Quackery}}==
<
$ " has no echo."
join
echo$</
{{out}}
Line 1,631 ⟶ 2,047:
=={{header|R}}==
<
paste(hello, "literal") # "hello literal"
hl <- paste(hello, "literal") #saves concatenates string to a new variable
paste("no", "spaces", "between", "words", sep="") # "nospacesbetweenwords"</
=={{header|Racket}}==
<
(define hello "hello")
(displayln hello)
Line 1,646 ⟶ 2,062:
;outputs:
; hello
; hello world!</
=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo|#22 "Thousand Oaks"}}
<syntaxhighlight lang="raku"
say $s ~ ' literal';
my $s1 = $s ~ ' literal';
Line 1,659 ⟶ 2,075:
$s ~= ' literal';
say $s;</
Note also that most concatenation in Raku is done implicitly via interpolation.
=={{header|Raven}}==
<
"First string and " "second string" cat print
Line 1,677 ⟶ 2,093:
# Heredoc
" - NOT!!" as $x
"This is the only way to do it%($x)s" print</
{{out}}
<pre>First string and second string
Line 1,687 ⟶ 2,103:
=={{header|REBOL}}==
<
print s1: rejoin [s " literal"]
print s1</
=={{header|Red}}==
<
>>str2: append str1 " World"
>> print str2
Hello World
>> print str1
Hello World</
=={{header|ReScript}}==
<syntaxhighlight lang="rescript">let s1 = "hello"
let s2 = s1 ++ " literal"
Js.log(s1)
Js.log(s2)
</syntaxhighlight>
{{output}}
<pre>$ bsc sc.res > sc.js
$ node sc.js
hello
hello literal
</pre>
=={{header|Retro}}==
<syntaxhighlight lang="retro">
'hello_ 'literal s:append s:put</
=={{header|REXX}}==
<
say s "literal"
t = s "literal" /*whitespace between the two strings causes a space in the output.*/
Line 1,712 ⟶ 2,142:
genus= "straw"
say genus"berry" /*this outputs strawberry.*/
say genus || "berry" /*concatenation using a double-pipe does not cause spaces.*/</
=={{header|Ring}}==
<
aString = "Welcome to the "
bString = "Ring Programming Language"
see astring + bString + nl
</syntaxhighlight>
=={{header|RPL}}==
This example showcases the 2 types of variables offered by RPL : temporary ones declared with <code>→</code> that disappear when the program ends, and persistent ones declared with the <code>STO</code> (for STOre) instruction.
≪ "Hello " → string1
≪ string1 " world" + 'string2' STO
string1 string2
≫
{{works with|Halcyon Calc|4.2.7}}
{{out}}
<pre>
2: "Hello"
1: "Hello world"
</pre>
=={{header|Ruby}}==
<
s = "hello"
Line 1,747 ⟶ 2,190:
puts s #=> "Alice said: hello literal"
</syntaxhighlight>
=={{header|Rust}}==
<
let s = "hello".to_owned();
println!("{}", s);
Line 1,756 ⟶ 2,199:
let s1 = s + " world";
println!("{}", s1);
}</
=={{header|SAS}}==
<
a="Hello,";
b="World!";
Line 1,767 ⟶ 2,210:
c=catx (" ", a, b);
put c;
run;</
=={{header|Sather}}==
<
main is
s ::= "hello";
Line 1,777 ⟶ 2,220:
#OUT + s2 + "\n";
end;
end;</
=={{header|S-BASIC}}==
<syntaxhighlight lang="basic">
rem - the + operator is used to concatenate strings
var s1, s2 = string
s1 = "Hello"
print s1 + ", world"
s2 = s1 + ", world"
print s2
end
</syntaxhighlight>
{{out}}
<pre>
Hello, world
Hello, world
</pre>
=={{header|Scala}}==
Evaluation in a Scala worksheet, to val f2 is an anonymous function assigned.
<
val s2 = s + " world" //> s2 : String = hello world
val f2 = () => " !" //> f2 : () => String = <function0>
println(s2 + f2()) //> hello world !</
=={{header|Scheme}}==
<
(display (string-append s " literal"))
(newline)
(define s1 (string-append s " literal"))
(display s1)
(newline)</
=={{header|Scilab}}==
<syntaxhighlight lang="text">s1="Hello"
s1+" world!"
s2=s1+" world"
s2
</syntaxhighlight>
{{out}}
<pre style="height:20ex> --> s1="Hello"
Line 1,813 ⟶ 2,277:
-->s2
Hello world! </pre>
=={{header|sed}}==
There are no variables in ''sed'', just two distinct locations for storing a string: The "pattern space" and the "hold space".
The pattern space contains the current input line. With the <code>h</code> command, it is copied to the hold space. Then, the <code>s</code> command appends a string literal to the pattern space:
<syntaxhighlight lang="sed">h
s/$/String Literal/</syntaxhighlight>
If necessary, the content of both spaces could be exchanged by a final <code>x</code> command.
=={{header|Seed7}}==
<
const proc: main is func
Line 1,825 ⟶ 2,297:
s2 := s & " world";
writeln(s2);
end func;</
{{out}}
<pre>
Line 1,833 ⟶ 2,305:
=={{header|Sidef}}==
<
say s+' literal';
var s1 = s+' literal';
say s1;</
An example of destructive concatenation:
<
say s;</
=={{header|Simula}}==
<
TEXT head, tail;
BEGIN TEXT c;
Line 1,855 ⟶ 2,327:
another :- concatenate(stringVariable, "and tail");
OutText("stringVariable: """); OutText(stringVariable);
OutText(""", another: "); OutText(another); Outimage;</
=={{header|Slate}}==
<
inform: s ; ' literal'.
define: #s1 -> (s ; ' literal').
inform: s1.</
=={{header|Slope}}==
<syntaxhighlight lang="slope">(define s1 "Hello")
(display (append s1 ", World!"))
</syntaxhighlight>
{{out}}
<pre>
Hello, World!
</pre>
=={{header|Smalltalk}}==
In Smalltalk "," (comma) is a binary message (virtual function) implemented by Collection (and therefore also understood by strings):
<
(s,' literal') printNl.
s1 := s,' literal'.
s1 printNl.</
=={{header|SNOBOL4}}==
<
output = greet1
greet2 = greet1 "World!"
output = greet2
end</
=={{header|Sparkling}}==
<
let s2 = " world!";
print(s1 .. s2); // prints "Hello world!"</
=={{header|Standard ML}}==
<
val s1 = s ^ " literal\n"
val () =
print (s ^ " literal\n");
print s1</
=={{header|Stata}}==
=== Stata string scalars ===
<
sca b = "bar"
sca c = a+b
di c
foobar</
=== Mata ===
<
b = "bar"
c = a+b
c
foobar</
=={{header|Swift}}==
<
println(s + " literal")
let s1 = s + " literal"
println(s1)</
=={{header|Symsyn}}==
<syntaxhighlight lang="symsyn">
| concatenate a string
Line 1,919 ⟶ 2,401:
$s []
</syntaxhighlight>
{{out}}
Line 1,928 ⟶ 2,410:
=={{header|Tailspin}}==
Tailspin has no operator for concatenating strings, you simply use interpolation instead
<
def a: 'Hello';
'$a;, World!' -> !OUT::write
</syntaxhighlight>
{{out}}
<pre>
Line 1,938 ⟶ 2,420:
=={{header|Tcl}}==
<
puts "$s there!"
append s " there!"
puts $s</
You can also just group the strings to concatenate together at the point where they are used, using Tcl's built-in syntactic concatenation:
<
set t "World"
set u "!"
puts $s$t$u ;# There is nothing special here about using puts; just an example</
=={{header|TI-83 BASIC}}==
<
Str0+" WORLD!"→Str0</
{{out}}
<pre>HELLO WORLD!</pre>
=={{header|TI-89 BASIC}}==
<
Disp sv & "vark"
sv & "wolf" → sv2</
=={{header|TorqueScript}}==
<
echo(%string);
%other = " world!";
echo(%other);
echo(%string @ %other);</
=={{header|Transd}}==
<syntaxhighlight lang="Scheme">#lang transd
MainModule: {
_start: (λ locals:
s1 "concat"
s2 (+ s1 "enation")
(lout "s1: " s1)
(lout "s2: " s2)
)
}</syntaxhighlight>
{{out}}
<pre>
s1: concat
s2: concatenation
</pre>
=={{header|TUSCRIPT}}==
<
s = "Hello "
print s, "literal"
s1 = CONCAT (s,"literal")
print s1</
{{out}}
<pre>
Line 1,978 ⟶ 2,477:
Hello literal
</pre>
=={{header|uBasic/4tH}}==
<syntaxhighlight lang="uBasic/4tH">
s := "Hello"
t = Join(s, " world!")
Print Show (s), Show (t)</syntaxhighlight>
{{out}}
<pre>Hello Hello world!
0 OK, 0:61</pre>
=={{header|UNIX Shell}}==
{{works with|Bourne Shell}} {{works with|bash}}
<
echo "$s literal"
s1="$s literal" # This method only works with a space between the strings
Line 1,989 ⟶ 2,498:
genus='straw'
fruit=${genus}berry # This outputs the word strawberry
echo $fruit</
=={{header|UnixPipes}}==
<
| xargs -n1 -i echo {} literal</
=={{header|Ursa}}==
<
# make s1 contain "hello "
set s1 "hello "
Line 2,004 ⟶ 2,513:
# outputs "hello world"
out s2 endl console</
=={{header|Uxntal}}==
<syntaxhighlight lang="Uxntal">|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|0100 @on-reset ( -> )
;str3 ;str1 copy-str
;str3 ;str2 append-str
;str3 print-str
#0a .Console/write DEO
BRK
@print-str ( str* -: )
&loop ( -- )
LDAk .Console/write DEO
INC2 LDAk ?&loop
POP2 JMP2r
@copy-str ( dest* src* -: )
STH2
&loop ( -- )
LDAkr STH2k STAr INC2 LDAkr STHr INC2r ?&loop
POP2 POP2r JMP2r
@append-str ( dest* src* -: )
STH2 end-str STH2r copy-str JMP2r
@end-str ( str* -: str* )
!&inner
&loop ( -- )
INC2 &inner LDAk ?&loop
JMP2r
@str1 "Uxn 00
@str2 "tal 00
@str3</syntaxhighlight>
=={{header|Vala}}==
<
var s = "hello";
print(s);
Line 2,013 ⟶ 2,557:
var s2 = s + " literal\n";
print(s2);
}</
=={{header|VBA}}==
<syntaxhighlight lang="vb">
Option Explicit
Line 2,029 ⟶ 2,573:
Debug.Print str2 & " based on concatenation of : " & str1 & " and code..."
End Sub
</syntaxhighlight>
{{out}}
<pre>
Line 2,037 ⟶ 2,581:
=={{header|VBScript}}==
<
s2=s1 & " World!"
WScript.Echo s2 </
{{out}}
<pre>
Line 2,053 ⟶ 2,597:
'''Platform:''' [[.NET]]
{{works with|Visual Basic .NET|9.0+}}
<
Console.WriteLine(s & " literal")
s1 = s + " literal"
Console.WriteLine(s1)</
=={{header|V (Vlang)}}==
<syntaxhighlight lang="v (vlang)">s := 'hello'
println(s)
println(s+' literal')
s2:= s+ ' literal'
println(s2)</syntaxhighlight>
{{out}}
<pre>
hello
hello literal
hello literal
</pre>
=={{header|Wee Basic}}==
<
let string2$="world!"
print 1 string1$+string2$
end</
=={{header|Wren}}==
<
var t = s + "world!"
System.print(s)
System.print(t)</
{{out}}
Line 2,077 ⟶ 2,637:
=={{header|XPL0}}==
<
char S1, S2, S3;
int C, I, J;
Line 2,099 ⟶ 2,659:
Concat(A, B, C);
Text(0, C);
]</
=={{header|Yorick}}==
<
var2 = var1 + ", world!";
write, var1;
write, var2;</
=={{header|Zig}}==
<
const debug = std.debug;
Line 2,138 ⟶ 2,698:
debug.warn("{}\n", .{hello_world_joined});
}</
{{out}}
Line 2,149 ⟶ 2,709:
=={{header|zkl}}==
<
s2:=s+", world!"; s2.println(); //-->Hello, world!
s3:=String(s," ",s2); s3.println(); //-->Hello Hello, world!</
Line 2,159 ⟶ 2,719:
=={{header|Zoea}}==
<syntaxhighlight lang="zoea">
program: string_concat
input: ['hello', 'literal']
output: 'hello literal'
</syntaxhighlight>
=={{header|Zoea Visual}}==
|