String concatenation: Difference between revisions

m
syntax highlighting fixup automation
m (syntax highlighting fixup automation)
Line 19:
{{trans|Python}}
 
<langsyntaxhighlight lang="11l">V s1 = ‘hello’
print(s1‘ world’)
V s2 = s1‘ world’
print(s2)</langsyntaxhighlight>
 
{{out}}
Line 32:
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
<syntaxhighlight lang="aarch64 assembly">
<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>
</lang>
{{Output}}
<pre>
Line 104:
 
=={{header|ABAP}}==
<langsyntaxhighlight ABAPlang="abap">DATA: s1 TYPE string,
s2 TYPE string.
 
Line 111:
WRITE: / s1.
WRITE: / s2.
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 118:
</pre>
===Another way===
<langsyntaxhighlight ABAPlang="abap">REPORT string_concatenation.
 
DATA(var1) = 'Hello'.
Line 131:
)->write( |{ var1 } world!|
)->display( ).
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 139:
 
=={{header|Action!}}==
<langsyntaxhighlight Actionlang="action!">PROC Append(CHAR ARRAY text,suffix)
BYTE POINTER srcPtr,dstPtr
BYTE len
Line 169:
PROC Main()
TestConcatenate("Hello", " World!")
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/String_concatenation.png Screenshot from Atari 8-bit computer]
Line 177:
 
=={{header|ActionScript}}==
<langsyntaxhighlight lang="actionscript">package
{
public class Str
Line 189:
}
}
}</langsyntaxhighlight>
 
=={{header|Ada}}==
<langsyntaxhighlight lang="ada">with Ada.Text_IO; use Ada.Text_IO;
 
procedure String_Concatenation is
Line 200:
Put_Line (S1);
Put_Line (S2);
end String_Concatenation;</langsyntaxhighlight>
{{out|Sample output}}
<pre>
Line 208:
 
=={{header|Aime}}==
<langsyntaxhighlight lang="aime">text s, v;
 
s = "Hello";
o_(s, "\n");
v = s + ", World!";
o_(v, "\n");</langsyntaxhighlight>
{{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]}}
<langsyntaxhighlight lang="algol68">STRING s := "hello";
print ((s + " literal", new line));
STRING s1 := s + " literal";
print ((s1, new line))</langsyntaxhighlight>
{{out}}
<pre>
Line 233:
 
=={{header|ALGOL-M}}==
<syntaxhighlight lang="algol">
<lang ALGOL>
begin
 
Line 250:
 
end
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 261:
=={{header|Apex}}==
 
<langsyntaxhighlight lang="apex">
String s1 = 'Hello ';
String s2 = 'Salesforce Developer!';
Line 268:
 
// Print output
System.debug(s3);</langsyntaxhighlight>
{{out}}
<pre>Hello Salesforce Developer!</pre>
 
=={{header|AppleScript}}==
<langsyntaxhighlight lang="applescript">try
set endMsg to "world!"
set totMsg to "Hello, " & endMsg
display dialog totMsg
end try</langsyntaxhighlight>
 
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
<syntaxhighlight lang="arm assembly">
<lang ARM Assembly>
/* ARM assembly Raspberry PI */
/* program strConcat.s */
Line 354:
bx lr @ return
 
</syntaxhighlight>
</lang>
 
=={{header|Arturo}}==
<langsyntaxhighlight lang="rebol">str1: "Hello "
str2: "World"
print str1 ++ str2 ++ "!"</langsyntaxhighlight>
 
{{out}}
Line 367:
 
=={{header|Asymptote}}==
<langsyntaxhighlight Asymptotelang="asymptote">string s1 = "Hello";
write(s1 + " World!");
write(s1, " World!");
string s2 = s1 + " World!";
write(s2);</langsyntaxhighlight>
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight AutoHotkeylang="autohotkey">s := "hello"
Msgbox, %s%
s1 := s . " literal" ;the . is optional
Msgbox, %s1%</langsyntaxhighlight>
 
=={{header|AWK}}==
The AWK concatenation operator is nothing.
<langsyntaxhighlight lang="awk">BEGIN {
s = "hello"
print s " literal"
s1 = s " literal"
print s1
}</langsyntaxhighlight>
 
=={{header|Axe}}==
<langsyntaxhighlight lang="axe">Lbl CONCAT
Copy(r₁,L₁,length(r₁))
Copy(r₂,L₁+length(r₁),length(r₂)+1)
L₁
Return</langsyntaxhighlight>
 
=={{header|BASIC}}==
Line 403:
{{works with|Run Basic}}
{{works with|Yabasic}}
<langsyntaxhighlight lang="qbasic">s$ = "hello"
print s$ + " literal"
s2$ = s$ + " literal"
print s$
print s2$</langsyntaxhighlight>
{{out}}
<pre>hello literal
Line 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.
 
<langsyntaxhighlight ApplesoftBasiclang="applesoftbasic">10 S$ = "HELLO"
20 PRINT S$ + " LITERAL"
30 PRINT S$
40 S2$ = S$ + " LITERAL"
50 PRINT S2$</langsyntaxhighlight>
 
{{out}}
Line 429:
 
==={{header|BaCon}}===
<langsyntaxhighlight lang="freebasic">
A$ = "hello"
PRINT A$," World"
Line 435:
A2$ = A$ & " using & to concat World"
PRINT A2$
</syntaxhighlight>
</lang>
 
==={{header|BBC BASIC}}===
<langsyntaxhighlight lang="bbcbasic"> stringvar1$ = "Hello,"
stringvar2$ = stringvar1$ + " world!"
PRINT "Variable 1 is """ stringvar1$ """"
PRINT "Variable 2 is """ stringvar2$ """"</langsyntaxhighlight>
{{out}}
<pre>Variable 1 is "Hello,"
Line 447:
 
==={{header|IS-BASIC}}===
<langsyntaxhighlight ISlang="is-BASICbasic">100 LET S$="Hello"
110 LET S$=S$&" world!"
120 PRINT S$</langsyntaxhighlight>
 
==={{header|BASIC256}}===
<langsyntaxhighlight lang="freebasic">s1$ = "Hello"
print s1$; " World!"
print s1$ + " World!"
Line 461:
print s2$
s2$ = s1$ & " World!"
print s2$</langsyntaxhighlight>
 
==={{header|Run BASIC}}===
{{works with|Liberty BASIC}}
<langsyntaxhighlight lang="runbasic">s1$ = "Hello"
print s1$; " World!"
print s1$ + " World!"
Line 471:
print s2$
s2$ = s1$ + " World!"
print s2$</langsyntaxhighlight>
 
==={{header|True BASIC}}===
{{works with|BASIC256}}
<langsyntaxhighlight lang="qbasic">LET s1$ = "Hello"
PRINT s1$; " World!"
PRINT s1$ + " World!"
LET s2$ = s1$ & " World!"
PRINT s2$
END</langsyntaxhighlight>
 
==={{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</langsyntaxhighlight>
==={{header|Yabasic}}===
{{works with|Liberty BASIC}}
Line 494:
{{works with|QBasic}}
{{works with|Run BASIC}}
<langsyntaxhighlight lang="yabasic">s1$ = "Hello"
print s1$, " World!"
print s1$ + " World!"
s2$ = s1$ + " World!"
print s2$</langsyntaxhighlight>
 
==={{header|ZX Spectrum Basic}}===
<langsyntaxhighlight lang="zxbasic">10 LET s$="Hello"
20 LET s$=s$+" World!"
30 PRINT s$</langsyntaxhighlight>
 
=={{header|Batch File}}==
<langsyntaxhighlight lang="dos">set string=Hello
echo %string% World
set string2=%string% World
echo %string2%</langsyntaxhighlight>
 
=={{header|BQN}}==
<code>∾</code>(Join) will concatenate two strings together.
 
<langsyntaxhighlight lang="bqn">str ← "Hello "
newstr ← str ∾ "world"
•Show newstr</langsyntaxhighlight>
<langsyntaxhighlight lang="bqn">"Hello world"</langsyntaxhighlight>
 
=={{header|Bracmat}}==
<langsyntaxhighlight lang="bracmat">"Hello ":?var1
& "World":?var2
& str$(!var1 !var2):?var12
& put$("var1=" !var1 ", var2=" !var2 ", var12=" !var12 "\n")</langsyntaxhighlight>
{{out}}
<pre>var1= Hello , var2= World , var12= Hello World</pre>
 
=={{header|Burlesque}}==
<langsyntaxhighlight lang="burlesque">blsq ) "Hello, ""world!"?+
"Hello, world!"</langsyntaxhighlight>
 
=={{header|C}}==
<langsyntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Line 556:
puts(s2);
free(s2);
}</langsyntaxhighlight>
 
=={{header|C sharp|C#}}==
<langsyntaxhighlight lang="csharp">using System;
 
class Program {
Line 569:
Console.WriteLine(s2);
}
}</langsyntaxhighlight>
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">#include <string>
#include <iostream>
 
Line 581:
std::cout << s2 << std::endl;
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>hello literal
Line 587:
 
=={{header|ChucK}}==
<syntaxhighlight lang="text">
"Hello" => string A;
A + " World!" => string B;
<<< B >>>;
</syntaxhighlight>
</lang>
{{out}}
<pre>"Hello World!"</pre>
 
=={{header|Clojure}}==
<langsyntaxhighlight lang="lisp">(def a-str "abcd")
(println (str a-str "efgh"))
 
(def a-new-str (str a-str "efgh"))
(println a-new-str)</langsyntaxhighlight>
 
=={{header|COBOL}}==
With the <code>STRING</code> verb:
<langsyntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. Concat.
 
Line 618:
 
GOBACK
.</langsyntaxhighlight>
Alternate method using the <code>CONCATENATE</code> intrinsic function:
<langsyntaxhighlight lang="cobol"> ...
PROCEDURE DIVISION.
DISPLAY "Str : " Str
Line 627:
 
GOBACK
.</langsyntaxhighlight>
 
String literals can also be concatenated in the follwing ways:
<langsyntaxhighlight lang="cobol">* *> Using a '&'.
01 Long-Str-Val PIC X(200) VALUE "Lorem ipsum dolor sit "
& "amet, consectetuer adipiscing elit, sed diam nonummy "
Line 640:
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".</langsyntaxhighlight>
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang="lisp">(let ((s "hello"))
(format t "~a there!~%" s)
(let* ((s2 " there!")
(s (concatenate 'string s s2)))
(format t "~a~%" s)))</langsyntaxhighlight>
<langsyntaxhighlight lang="lisp">(defparameter *s* "hello")
(print (concatenate 'string *s* " literal"))
(defparameter *s1* (concatenate 'string *s* " literal"))
(print *s1*)</langsyntaxhighlight>
 
=={{header|Component Pascal}}==
BlackBox Component Builder
<langsyntaxhighlight lang="oberon2">
MODULE StringConcatenation;
IMPORT StdLog;
Line 669:
 
END StringConcatenation.
</syntaxhighlight>
</lang>
Execute: ^Q StringConcatenation.Do<br/>
{{out}}
Line 677:
 
=={{header|D}}==
<langsyntaxhighlight lang="d">import std.stdio;
void main() {
Line 684:
auto s2 = s ~ " world";
writeln(s2);
}</langsyntaxhighlight>
 
=={{header|DCL}}==
<langsyntaxhighlight DCLlang="dcl">$ string1 = "hello"
$ string2 = string1 + " world"
$ show symbol string*</langsyntaxhighlight>
{{out}}
<pre> STRING1 = "hello"
Line 695:
 
=={{header|Delphi}}==
<langsyntaxhighlight lang="delphi">program Concat;
 
{$APPTYPE CONSOLE}
Line 706:
WriteLn(s1);
WriteLn(s2);
end.</langsyntaxhighlight>
 
=={{header|DWScript}}==
<langsyntaxhighlight lang="delphi">var s1 := 'Hello';
var s2 := s1 + ' World';
 
PrintLn(s1);
PrintLn(s2);</langsyntaxhighlight>
 
=={{header|Dyalect}}==
Line 719:
{{trans|Swift}}
 
<langsyntaxhighlight Dyalectlang="dyalect">var s = "hello"
print(s + " literal")
var s1 = s + " literal"
print(s1)</langsyntaxhighlight>
 
=={{header|Dylan.NET}}==
<syntaxhighlight lang="dylan.net">
<lang Dylan.NET>
//to be compiled using dylan.NET v. 11.5.1.2 or later.
#refstdasm mscorlib.dll
Line 744:
end method
 
end class</langsyntaxhighlight>
 
=={{header|Déjà Vu}}==
<langsyntaxhighlight lang="dejavu">local :s1 "hello"
local :s2 concat( s1 ", world" )
!print s2</langsyntaxhighlight>
{{out}}
<pre>hello, world</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight lang="text">a$ = "hello"
b$ = a$ & " world"
print b$</langsyntaxhighlight>
 
=={{header|Ela}}==
Strings in Ela support a polymorphic concatenation operator (++):
<langsyntaxhighlight lang="ela">hello = "Hello"
hello'world = hello ++ ", " ++ "world"
(hello, hello'world)</langsyntaxhighlight>
{{out}}
<pre>("Hello", "Hello, world!")</pre>
Line 768:
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:
<langsyntaxhighlight lang="ela">toString $ "Hello" +> ", " +> "world"</langsyntaxhighlight>
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 775:
=={{header|Elena}}==
ELENA 4.x:
<langsyntaxhighlight lang="elena">public program()
{
var s := "Hello";
Line 783:
console.writeLine:s2;
console.readChar()
}</langsyntaxhighlight>
{{out}}
<pre>
Line 791:
 
=={{header|Elixir}}==
<langsyntaxhighlight lang="elixir">
s = "hello"
t = s <> " literal"
Line 797:
IO.puts s
IO.puts t
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 806:
=={{header|Emacs Lisp}}==
 
<langsyntaxhighlight Lisplang="lisp">(defvar foo "foo")
(defvar foobar (concat foo "bar"))
(message "%sbar" foo)
(message "%s" foobar)</langsyntaxhighlight>
 
{{out}}
Line 817:
 
=={{header|Erlang}}==
<langsyntaxhighlight Erlanglang="erlang">S = "hello",
S1 = S ++ " literal",
io:format ("~s literal~n",[S]),
io:format ("~s~n",[S1])</langsyntaxhighlight>
{{out|Sample output}}
<pre>
Line 828:
 
=={{header|ERRE}}==
<syntaxhighlight lang="erre">
<lang ERRE>
..........
S$="HELLO"
Line 835:
PRINT(S2$)
..........
</syntaxhighlight>
</lang>
 
=={{header|Euphoria}}==
<langsyntaxhighlight Euphorialang="euphoria">sequence s, s1
s = "hello"
puts(1, s & " literal")
Line 844:
s1 = s & " literal"
print (1, s1))
puts(1,'\n')</langsyntaxhighlight>
{{out}}
hello literal
Line 852:
Take three cells, say A1,B1 and C1. In C1, type in :
 
<langsyntaxhighlight lang="excel">
 
=CONCATENATE(A1;" ";B1)
 
</syntaxhighlight>
</lang>
 
As the text in A1 and/or B1 is changed, C1 will be updated.
 
<syntaxhighlight lang="text">
Hello World Hello World
</syntaxhighlight>
</lang>
 
=={{header|F_Sharp|F#}}==
{{trans|C#}}
<langsyntaxhighlight lang="fsharp">open System
 
[<EntryPoint>]
Line 875:
let s2 = s + " literal"
Console.WriteLine(s2)
0</langsyntaxhighlight>
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">"wake up" [ " sheeple" append print ] [ ", you sheep" append ] bi print</langsyntaxhighlight>
 
=={{header|Falcon}}==
'''VBA/Python programmer's approach. I'm just a junior Falconeer but this code seems falconic''
<langsyntaxhighlight lang="falcon">
/* created by Aykayayciti Earl Lamont Montgomery
April 9th, 2018 */
Line 890:
s2 = s + " literal"
> s2
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 900:
=={{header|Fantom}}==
Illustrating in <tt>fansh</tt>:
<langsyntaxhighlight lang="fantom">fansh> a := "abc"
abc
fansh> b := a + "def"
Line 907:
abc
fansh> b
abcdef</langsyntaxhighlight>
 
=={{header|Forth}}==
{{works with|GNU Forth}}
<langsyntaxhighlight lang="forth">s" hello" pad place
pad count type
s" there!" pad +place \ +place is called "append" on some Forths
pad count type</langsyntaxhighlight>
 
=={{header|Fortran}}==
<langsyntaxhighlight lang="fortran">program StringConcatenation
 
integer, parameter :: maxstringlength = 64
Line 926:
print *,s1
 
end program</langsyntaxhighlight>
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
Var s1 = "String"
Line 935:
Print s1
Print s2
Sleep</langsyntaxhighlight>
 
{{out}}
Line 944:
 
=={{header|Frink}}==
<langsyntaxhighlight lang="frink">
a = "Frink"
b = a + " rules!"
println[b]
</syntaxhighlight>
</lang>
 
=={{header|FutureBasic}}==
<langsyntaxhighlight lang="futurebasic">window 1
 
CFStringRef s1, s2
Line 961:
print s2
 
HandleEvents</langsyntaxhighlight>
 
=={{header|Gambas}}==
Line 967:
 
'''[https://gambas-playground.proko.eu/?gist=098450adbbe0e284f0b9cdac67d74dda Click this link to run this code]'''
<langsyntaxhighlight lang="gambas">Public sub main()
DIM bestclub AS String
DIM myconcat AS String
Line 976:
Print myconcat
 
End</langsyntaxhighlight>
 
=={{header|GlovePIE}}==
<langsyntaxhighlight lang="glovepie">var.text1="Hello, "
debug=var.text1+"world!"</langsyntaxhighlight>
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import "fmt"
Line 1,003:
// output second string variable
fmt.Println(s2)
}</langsyntaxhighlight>
{{out}}
<pre>
Line 1,012:
 
=={{header|Golfscript}}==
<langsyntaxhighlight lang="golfscript">"Greetings ":s;
s"Earthlings"+puts
s"Earthlings"+:s1;
s1 puts</langsyntaxhighlight>
 
=={{header|Groovy}}==
<langsyntaxhighlight lang="groovy">def s = "Greetings "
println s + "Earthlings"
 
def s1 = s + "Earthlings"
println s1</langsyntaxhighlight>
{{out}}
<pre>Greetings Earthlings
Line 1,029:
=={{header|Halon}}==
The dot (concatenation) operator may cast datatypes to strings.
<langsyntaxhighlight lang="halon">echo "Hello" . "World " . 123;</langsyntaxhighlight>
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import System.IO
s = "hello"
s1 = s ++ " literal"
main = do putStrLn (s ++ " literal")
putStrLn s1</langsyntaxhighlight>
 
=={{header|HicEst}}==
<langsyntaxhighlight HicEstlang="hicest">CHARACTER s = "hello", sl*100
 
WRITE() s // " literal"
sl = s // " literal"
WRITE() sl</langsyntaxhighlight>
 
=={{header|Icon}} and {{header|Unicon}}==
<langsyntaxhighlight Iconlang="icon">procedure main()
s1 := "hello"
write(s2 := s1 || " there.") # capture the reuslt for
write(s2) # ... the 2nd write
end</langsyntaxhighlight>
 
=={{header|IDL}}==
<langsyntaxhighlight lang="idl">s1='Hello'
print, s1 + ' literal'
s2=s1 + ' literal'
print, s2</langsyntaxhighlight>
 
=={{header|J}}==
<langsyntaxhighlight Jlang="j"> s1 =. 'Some '
]s1, 'text '
Some text
]s2 =. s1 , 'more text!'
Some more text!</langsyntaxhighlight>
For more info see:
* http://www.jsoftware.com/help/dictionary/d320.htm on <code>,</code>
Line 1,069:
 
=={{header|Java}}==
<langsyntaxhighlight lang="java5">public class Str{
public static void main(String[] args){
String s = "hello";
Line 1,076:
System.out.println(s2);
}
}</langsyntaxhighlight>
{{out}}
<pre>hello literal
Line 1,082:
 
=={{header|JavaScript}}==
<langsyntaxhighlight lang="javascript">var s = "hello"
print(s + " there!")</langsyntaxhighlight>
 
=={{header|jq}}==
<langsyntaxhighlight lang="jq">"hello" as $s | $s + " there!"</langsyntaxhighlight>
{{Out}}
# Use the -r command-line option if you wish
Line 1,093:
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">s = "hello"
println(s * " there!")</langsyntaxhighlight>
 
=={{header|K}}==
Translation of <b>J</b> code:
<syntaxhighlight lang="k">
<lang K>
s1: "Some "
s1, "text "
s2: s1 , "more text!"
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,111:
 
=={{header|Kotlin}}==
<langsyntaxhighlight lang="scala">fun main(args: Array<String>) {
val s1 = "James"
val s2 = "Bond"
Line 1,118:
val s3 = s1 + " " + s2
println(s3)
}</langsyntaxhighlight>
{{Out}}
<pre>James
Line 1,133:
=={{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">
<lang Scheme>
{def christian_name Albert}
-> christian_name
Line 1,141:
{christian_name} {name}
-> Albert de Jeumont-Schneidre
</syntaxhighlight>
</lang>
 
=={{header|Lang5}}==
<langsyntaxhighlight lang="lang5">: concat 2 compress "" join ;
'hello " literal" concat</langsyntaxhighlight>
 
=={{header|Lasso}}==
<langsyntaxhighlight Lassolang="lasso">local(x = 'Hello')
local(y = #x + ', World!')
#x // Hello
#y // Hello, World!</langsyntaxhighlight>
 
=={{header|Liberty BASIC}}==
Line 1,157:
 
=={{header|Lingo}}==
<langsyntaxhighlight lang="lingo">a = "Hello"
b = a & " world!"
put b
-- "Hello world!"</langsyntaxhighlight>
 
=={{header|Lisaac}}==
<langsyntaxhighlight Lisaaclang="lisaac">Section Header
 
+ name := STRING_CONCATENATION;
Line 1,179:
sv.println;
 
);</langsyntaxhighlight>
 
=={{header|LiveCode}}==
<langsyntaxhighlight LiveCodelang="livecode">local str="live"
put str & "code" into str2
put str && str2</langsyntaxhighlight>
Output<pre>live livecode</pre>
 
=={{header|Logo}}==
<langsyntaxhighlight lang="logo">make "s "hello
print word :s "| there!|</langsyntaxhighlight>
 
=={{header|Lua}}==
<langsyntaxhighlight lang="lua">a = "hello "
print(a .. "world")
c = a .. "world"
print(c)</langsyntaxhighlight>
 
=={{header|M2000 Interpreter}}==
Line 1,202:
A memory word is two bytes.
 
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module CheckString {
s$ = "hello"
Line 1,219:
}
CheckString
</syntaxhighlight>
</lang>
 
=={{header|M4}}==
M4 has macros rather than variables, but a macro expanded can work like a variable.
<langsyntaxhighlight lang="m4">define(`concat',`$1$2')dnl
define(`A',`any text value')dnl
concat(`A',` concatenated with string literal')
define(`B',`concat(`A',` and string literal')')dnl
B</langsyntaxhighlight>
 
=={{header|Maple}}==
<langsyntaxhighlight Maplelang="maple">str := "Hello":
newstr := cat(str,", world!"):
str;
newstr;</langsyntaxhighlight>
{{out}}
<pre>
Line 1,258:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">str= "Hello ";
str<>"Literal"</langsyntaxhighlight>
 
=={{header|MATLAB}} / {{header|Octave}}==
<langsyntaxhighlight MATLABlang="matlab">>> string1 = '1 Fish'
 
string1 =
Line 1,272:
string2 =
 
1 Fish, 2 Fish, Red Fish, Blue Fish</langsyntaxhighlight>
 
=={{header|Maxima}}==
<langsyntaxhighlight lang="maxima">s: "the quick brown fox";
t: "jumps over the lazy dog";
sconcat(s, " ", t);
/* "the quick brown fox jumps over the lazy dog" */</langsyntaxhighlight>
 
=={{header|MAXScript}}==
<langsyntaxhighlight lang="maxscript">s = "hello"
print (s + " literal")
s1 = s + " literal"
print s1</langsyntaxhighlight>
 
=={{header|Mercury}}==
<langsyntaxhighlight lang="mercury">:- module string_concat.
:- interface.
 
Line 1,300:
S1 = S ++ " world",
io.write_string(S, !IO), io.nl(!IO),
io.write_string(S1, !IO), io.nl(!IO).</langsyntaxhighlight>
 
=={{header|Metafont}}==
<langsyntaxhighlight lang="metafont">string a, b;
a := "String";
message a & " literal";
b := a & " literal";
message b;</langsyntaxhighlight>
 
=={{header|min}}==
{{works with|min|0.19.3}}
<langsyntaxhighlight lang="min">"butter" :a
(a "scotch")=> "" join :b
a puts!
b puts!</langsyntaxhighlight>
{{out}}
<pre>
Line 1,322:
 
=={{header|MiniScript}}==
<langsyntaxhighlight MiniScriptlang="miniscript">s = "hello"
print s + " world!"</langsyntaxhighlight>
 
{{output}}
Line 1,331:
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.
 
<langsyntaxhighlight lang="mips">main:
la $a0,String1
la $a1,UserRam
Line 1,369:
.ascii "lmnopqrstuvwxyz"
.byte 0
.align 4</langsyntaxhighlight>
{{out}}
<pre>abcdefghijklmnopqrstuvwxyz</pre>
Line 1,375:
=={{header|Modula-3}}==
Strings in Modula-3 are called <code>TEXT</code>s. Concatenation can use <code>&</code>, just like [[Ada]].
<langsyntaxhighlight lang="modula3">MODULE Concat EXPORTS Main;
 
IMPORT IO;
Line 1,386:
string1 := string & " literal.\n";
IO.Put(string1);
END Concat.</langsyntaxhighlight>
Modula-3 also provides modules for dealing with <code>TEXT</code>s, such as <code>Text</code>.
<langsyntaxhighlight lang="modula3">string1 := Text.Concat(string, " literal.\n");</langsyntaxhighlight>
 
=={{header|MUMPS}}==
<langsyntaxhighlight MUMPSlang="mumps">STRCAT
SET S="STRING"
WRITE !,S
SET T=S_" LITERAL"
WRITE !,T
QUIT</langsyntaxhighlight>
{{out}}
<pre>
Line 1,406:
 
=={{header|Nanoquery}}==
<langsyntaxhighlight Nanoquerylang="nanoquery">s1 = "hello"
println s1 + " world"
 
s2 = s1 + " world"
println s2</langsyntaxhighlight>
{{out}}
<pre>hello world
Line 1,416:
 
=={{header|Neko}}==
<syntaxhighlight lang="actionscript">/**
<lang ActionScript>/**
String concatenation, in Neko
Tectonics:
Line 1,437:
$print("addon: ", addon, "\n")
$print("c: ", c, "\n")
}</langsyntaxhighlight>
 
{{out}}
Line 1,449:
=={{header|Nemerle}}==
Can be done with Concat() method or + operator:
<langsyntaxhighlight Nemerlelang="nemerle">using System;
using System.Console;
using Nemerle.Utility.NString; // contains method Concat()
Line 1,462:
Write($"$cat1\n$cat2\n");
}
}</langsyntaxhighlight>
 
=={{header|NetRexx}}==
<langsyntaxhighlight NetRexxlang="netrexx">/* NetRexx */
 
options replace format comments java crossref savelog symbols
Line 1,484:
say 's6:' s6
say 's7:' s7
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,496:
 
=={{header|NewLISP}}==
<langsyntaxhighlight NewLISPlang="newlisp">(let (str1 "foo")
(println str1)
(let (str2 (string str1 "bar"))
(println str2)))</langsyntaxhighlight>
 
=={{header|Nim}}==
Strings can be concatenated with <code>&</code>.
<langsyntaxhighlight lang="nim">let str = "String"
echo str & " literal."
 
# -> String literal.</langsyntaxhighlight>
 
Strings can be concatenated as arrays and joined with separating characters:
<langsyntaxhighlight lang="nim">import strutils
var str = "String"
echo join([str, " literal.", "HelloWorld!"], "~~")
 
# -> String~~ literal.~~HelloWorld!</langsyntaxhighlight>
 
Strings can be combined using string formatting:
<langsyntaxhighlight lang="nim">import strutils
 
var str = "String"
Line 1,524:
# Alternate form providing automatic conversion of arguments to strings.
echo "$# $# $#".format(str, 123, "HelloWorld!")
# -> String 123 HelloWorld!</langsyntaxhighlight>
 
=={{header|NS-HUBASIC}}==
<langsyntaxhighlight NSlang="ns-HUBASIChubasic">10 STRING$="HELLO"
20 STRING$=STRING$+" WORLD!"
30 PRINT STRING$</langsyntaxhighlight>
 
=={{header|Objeck}}==
<langsyntaxhighlight lang="objeck">bundle Default {
class Repeat {
function : Main(args : String[]) ~ Nil {
Line 1,542:
}
}
}</langsyntaxhighlight>
 
=={{header|Objective-C}}==
<langsyntaxhighlight lang="objc">#import <Foundation/Foundation.h>
 
int main()
Line 1,564:
}
return 0;
}</langsyntaxhighlight>
 
=={{header|OCaml}}==
<langsyntaxhighlight lang="ocaml">let s = "hello"
let s1 = s ^ " literal"
let () =
print_endline (s ^ " literal");
print_endline s1</langsyntaxhighlight>
 
=={{header|Oforth}}==
 
.s show the stack :
<langsyntaxhighlight Oforthlang="oforth">"Hello" dup " World!" + .s </langsyntaxhighlight>
 
{{out}}
Line 1,585:
 
=={{header|Openscad}}==
<langsyntaxhighlight lang="openscad">a="straw";
b="berry";
c=str(a,b); /* Concatenate a and b */
echo (c);</langsyntaxhighlight>
 
=={{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"].
<langsyntaxhighlight lang="oz">declare
S = "hello"
{System.showInfo S#" literal"} %% virtual strings are constructed with "#"
S1 = {Append S " literal"}
{System.showInfo S1}</langsyntaxhighlight>
 
=={{header|PARI/GP}}==
<langsyntaxhighlight lang="parigp">s = "Hello ";
s = Str(s, "world");
\\ Alternately, this could have been:
\\ s = concat(s, "world");
print(s);</langsyntaxhighlight>
 
=={{header|Pascal}}==
<langsyntaxhighlight lang="pascal">Program StringConcat;
Var
s, s1 : String;
Line 1,616:
{ s1 := s + ' literal'; works too, with FreePascal }
writeln(s1);
End.</langsyntaxhighlight>
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">my $s = 'hello';
print $s . ' literal', "\n";
my $s1 = $s . ' literal';
print $s1, "\n";</langsyntaxhighlight>
An example of destructive concatenation:
<langsyntaxhighlight lang="perl">$s .= ' literal';
print $s, "\n";</langsyntaxhighlight>
 
=={{header|Phix}}==
{{libheader|Phix/basics}}
<!--<langsyntaxhighlight Phixlang="phix">-->
<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,635:
<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>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,647:
=={{header|PHL}}==
 
<syntaxhighlight lang="text">module stringcat;
 
extern printf;
Line 1,657:
 
return 0;
]</langsyntaxhighlight>
 
=={{header|PHP}}==
<langsyntaxhighlight lang="php"><?php
$s = "hello";
echo $s . " literal" . "\n";
$s1 = $s . " literal";
echo $s1 . "\n";
?></langsyntaxhighlight>
 
=={{header|Picat}}==
<langsyntaxhighlight Picatlang="picat">main =>
Hello = "Hello, ",
print(Hello ++ "world!" ++ "\n"),
String = Hello ++ "world!",
String := String ++ "\n",
print(String).</langsyntaxhighlight>
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(let Str1 "First text"
(prinl Str1 " literal")
(let Str2 (pack Str1 " literal")
(prinl Str2) ) )</langsyntaxhighlight>
 
=={{header|Pike}}==
<syntaxhighlight lang="pike">
<lang Pike>
string hello = "hello ";
write(hello + "world" + "\n");
string all_of_it = hello + "world";
write(all_of_it + "\n");
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 1,695:
 
=={{header|PL/I}}==
<langsyntaxhighlight PLlang="pl/Ii">declare (s, t) character (30) varying;
 
s = 'hello from me';
display (s || ' to you.' );
t = s || ' to you all';
display (t);</langsyntaxhighlight>
 
=={{header|Plain English}}==
Strings (and other values) can be concatenated to strings with <code>then</code>.
<langsyntaxhighlight lang="plainenglish">To run:
Start up.
Put "hello" into a string.
Line 1,711:
Write the other string to the console.
Wait for the escape key.
Shut down.</langsyntaxhighlight>
{{out}}
<pre>
Line 1,719:
 
=={{header|PowerShell}}==
<langsyntaxhighlight lang="powershell">$s = "Hello"
Write-Host $s World.
 
Line 1,726:
 
$s2 = $s + " World."
Write-Host $s2</langsyntaxhighlight>
 
=={{header|PureBasic}}==
<langsyntaxhighlight PureBasiclang="purebasic">If OpenConsole()
 
s$ = "hello"
Line 1,739:
Input()
CloseConsole()
EndIf</langsyntaxhighlight>
 
=={{header|Python}}==
<langsyntaxhighlight lang="python">s1 = "hello"
print s1 + " world"
 
s2 = s1 + " world"
print s2</langsyntaxhighlight>
{{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.
<langsyntaxhighlight lang="python">s1 = "hello"
print ", ".join([s1, "world", "mom"])
 
s2 = ", ".join([s1, "world", "mom"])
print s2</langsyntaxhighlight>
{{out}}
<pre>hello, world, mom
Line 1,761:
 
=={{header|QB64}}==
<langsyntaxhighlight lang="qbasic">s1$ = "String"
s2$ = s1$ + " concatenation"
Print s1$
Print s2$</langsyntaxhighlight>
{{out}}
<pre>
Line 1,773:
=={{header|Quackery}}==
 
<langsyntaxhighlight Quackerylang="quackery"> $ "A duck's quack"
$ " has no echo."
join
echo$</langsyntaxhighlight>
 
{{out}}
Line 1,783:
 
=={{header|R}}==
<langsyntaxhighlight Rlang="r">hello <- "hello"
paste(hello, "literal") # "hello literal"
hl <- paste(hello, "literal") #saves concatenates string to a new variable
paste("no", "spaces", "between", "words", sep="") # "nospacesbetweenwords"</langsyntaxhighlight>
 
=={{header|Racket}}==
<langsyntaxhighlight Racketlang="racket">#lang racket
(define hello "hello")
(displayln hello)
Line 1,798:
;outputs:
; hello
; hello world!</langsyntaxhighlight>
 
=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo|#22 "Thousand Oaks"}}
<syntaxhighlight lang="raku" perl6line>my $s = 'hello';
say $s ~ ' literal';
my $s1 = $s ~ ' literal';
Line 1,811:
 
$s ~= ' literal';
say $s;</langsyntaxhighlight>
Note also that most concatenation in Raku is done implicitly via interpolation.
 
=={{header|Raven}}==
<langsyntaxhighlight Ravenlang="raven"># Cat strings
"First string and " "second string" cat print
 
Line 1,829:
# Heredoc
" - NOT!!" as $x
"This is the only way to do it%($x)s" print</langsyntaxhighlight>
{{out}}
<pre>First string and second string
Line 1,839:
 
=={{header|REBOL}}==
<langsyntaxhighlight REBOLlang="rebol">s: "hello"
print s1: rejoin [s " literal"]
print s1</langsyntaxhighlight>
 
=={{header|Red}}==
<langsyntaxhighlight Redlang="red">>>str1: "Hello"
>>str2: append str1 " World"
>> print str2
Hello World
>> print str1
Hello World</langsyntaxhighlight>
 
=={{header|ReScript}}==
<langsyntaxhighlight lang="rescript">let s1 = "hello"
let s2 = s1 ++ " literal"
 
Js.log(s1)
Js.log(s2)
</syntaxhighlight>
</lang>
{{output}}
<pre>$ bsc sc.res > sc.js
Line 1,866:
 
=={{header|Retro}}==
<syntaxhighlight lang="retro">
<lang Retro>
'hello_ 'literal s:append s:put</langsyntaxhighlight>
 
=={{header|REXX}}==
<langsyntaxhighlight lang="rexx">s = "hello"
say s "literal"
t = s "literal" /*whitespace between the two strings causes a space in the output.*/
Line 1,878:
genus= "straw"
say genus"berry" /*this outputs strawberry.*/
say genus || "berry" /*concatenation using a double-pipe does not cause spaces.*/</langsyntaxhighlight>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
aString = "Welcome to the "
bString = "Ring Programming Language"
 
see astring + bString + nl
</syntaxhighlight>
</lang>
 
=={{header|Ruby}}==
<langsyntaxhighlight lang="ruby">
s = "hello"
 
Line 1,913:
puts s #=> "Alice said: hello literal"
 
</syntaxhighlight>
</lang>
 
=={{header|Rust}}==
<langsyntaxhighlight lang="rust">fn main() {
let s = "hello".to_owned();
println!("{}", s);
Line 1,922:
let s1 = s + " world";
println!("{}", s1);
}</langsyntaxhighlight>
 
=={{header|SAS}}==
<langsyntaxhighlight lang="sas">data _null_;
a="Hello,";
b="World!";
Line 1,933:
c=catx (" ", a, b);
put c;
run;</langsyntaxhighlight>
 
=={{header|Sather}}==
<langsyntaxhighlight lang="sather">class MAIN is
main is
s ::= "hello";
Line 1,943:
#OUT + s2 + "\n";
end;
end;</langsyntaxhighlight>
 
=={{header|S-BASIC}}==
<syntaxhighlight lang="basic">
<lang BASIC>
rem - the + operator is used to concatenate strings
 
Line 1,958:
 
end
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,968:
=={{header|Scala}}==
Evaluation in a Scala worksheet, to val f2 is an anonymous function assigned.
<langsyntaxhighlight lang="scala"> val s = "hello" //> s : String = hello
val s2 = s + " world" //> s2 : String = hello world
val f2 = () => " !" //> f2 : () => String = <function0>
 
println(s2 + f2()) //> hello world !</langsyntaxhighlight>
 
=={{header|Scheme}}==
<langsyntaxhighlight lang="scheme">(define s "hello")
(display (string-append s " literal"))
(newline)
(define s1 (string-append s " literal"))
(display s1)
(newline)</langsyntaxhighlight>
 
=={{header|Scilab}}==
<syntaxhighlight lang="text">s1="Hello"
s1+" world!"
s2=s1+" world"
s2
</syntaxhighlight>
</lang>
{{out}}
<pre style="height:20ex> --> s1="Hello"
Line 2,002:
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
const proc: main is func
Line 2,012:
s2 := s & " world";
writeln(s2);
end func;</langsyntaxhighlight>
{{out}}
<pre>
Line 2,020:
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">var s = 'hello';
say s+' literal';
var s1 = s+' literal';
say s1;</langsyntaxhighlight>
An example of destructive concatenation:
<langsyntaxhighlight lang="ruby">s += ' literal';
say s;</langsyntaxhighlight>
 
=={{header|Simula}}==
<langsyntaxhighlight Simulalang="simula">TEXT PROCEDURE concatenate(head, tail);
TEXT head, tail;
BEGIN TEXT c;
Line 2,042:
another :- concatenate(stringVariable, "and tail");
OutText("stringVariable: """); OutText(stringVariable);
OutText(""", another: "); OutText(another); Outimage;</langsyntaxhighlight>
 
=={{header|Slate}}==
<langsyntaxhighlight lang="slate">define: #s -> 'hello'.
inform: s ; ' literal'.
define: #s1 -> (s ; ' literal').
inform: s1.</langsyntaxhighlight>
 
=={{header|Smalltalk}}==
In Smalltalk "," (comma) is a binary message (virtual function) implemented by Collection (and therefore also understood by strings):
 
<langsyntaxhighlight lang="smalltalk">|s s1| s := 'hello'.
(s,' literal') printNl.
s1 := s,' literal'.
s1 printNl.</langsyntaxhighlight>
 
=={{header|SNOBOL4}}==
<langsyntaxhighlight lang="snobol"> greet1 = "Hello, "
output = greet1
greet2 = greet1 "World!"
output = greet2
end</langsyntaxhighlight>
 
=={{header|Sparkling}}==
<langsyntaxhighlight lang="sparkling">let s1 = "Hello";
let s2 = " world!";
print(s1 .. s2); // prints "Hello world!"</langsyntaxhighlight>
 
=={{header|Standard ML}}==
<langsyntaxhighlight lang="sml">val s = "hello"
val s1 = s ^ " literal\n"
val () =
print (s ^ " literal\n");
print s1</langsyntaxhighlight>
 
=={{header|Stata}}==
=== Stata string scalars ===
<langsyntaxhighlight lang="stata">sca a = "foo"
sca b = "bar"
sca c = a+b
di c
foobar</langsyntaxhighlight>
 
=== Mata ===
<langsyntaxhighlight lang="stata">a = "foo"
b = "bar"
c = a+b
c
foobar</langsyntaxhighlight>
 
=={{header|Swift}}==
<langsyntaxhighlight lang="swift">let s = "hello"
println(s + " literal")
let s1 = s + " literal"
println(s1)</langsyntaxhighlight>
 
=={{header|Symsyn}}==
<syntaxhighlight lang="symsyn">
<lang Symsyn>
| concatenate a string
 
Line 2,106:
$s []
 
</syntaxhighlight>
</lang>
 
{{out}}
Line 2,115:
=={{header|Tailspin}}==
Tailspin has no operator for concatenating strings, you simply use interpolation instead
<langsyntaxhighlight lang="tailspin">
def a: 'Hello';
'$a;, World!' -> !OUT::write
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 2,125:
 
=={{header|Tcl}}==
<langsyntaxhighlight lang="tcl">set s hello
puts "$s there!"
append s " there!"
puts $s</langsyntaxhighlight>
You can also just group the strings to concatenate together at the point where they are used, using Tcl's built-in syntactic concatenation:
<langsyntaxhighlight lang="tcl">set s "Hello "
set t "World"
set u "!"
puts $s$t$u ;# There is nothing special here about using puts; just an example</langsyntaxhighlight>
 
=={{header|TI-83 BASIC}}==
<langsyntaxhighlight lang="ti83b">"HELLO"→Str0
Str0+" WORLD!"→Str0</langsyntaxhighlight>
{{out}}
<pre>HELLO WORLD!</pre>
 
=={{header|TI-89 BASIC}}==
<langsyntaxhighlight lang="ti89b">"aard" → sv
Disp sv & "vark"
sv & "wolf" → sv2</langsyntaxhighlight>
 
=={{header|TorqueScript}}==
<langsyntaxhighlight Torquelang="torque">%string = "Hello";
echo(%string);
%other = " world!";
echo(%other);
echo(%string @ %other);</langsyntaxhighlight>
 
=={{header|TUSCRIPT}}==
<langsyntaxhighlight lang="tuscript">$$ MODE TUSCRIPT
s = "Hello "
print s, "literal"
 
s1 = CONCAT (s,"literal")
print s1</langsyntaxhighlight>
{{out}}
<pre>
Line 2,168:
=={{header|UNIX Shell}}==
{{works with|Bourne Shell}} {{works with|bash}}
<langsyntaxhighlight lang="sh">s="hello"
echo "$s literal"
s1="$s literal" # This method only works with a space between the strings
Line 2,176:
genus='straw'
fruit=${genus}berry # This outputs the word strawberry
echo $fruit</langsyntaxhighlight>
 
=={{header|UnixPipes}}==
<langsyntaxhighlight lang="bash">echo "hello"
| xargs -n1 -i echo {} literal</langsyntaxhighlight>
 
=={{header|Ursa}}==
<langsyntaxhighlight lang="ursa">decl string s1 s2
# make s1 contain "hello "
set s1 "hello "
Line 2,191:
 
# outputs "hello world"
out s2 endl console</langsyntaxhighlight>
 
=={{header|Vala}}==
<langsyntaxhighlight lang="vala">void main() {
var s = "hello";
print(s);
Line 2,200:
var s2 = s + " literal\n";
print(s2);
}</langsyntaxhighlight>
 
=={{header|VBA}}==
 
<syntaxhighlight lang="vb">
<lang vb>
Option Explicit
 
Line 2,216:
Debug.Print str2 & " based on concatenation of : " & str1 & " and code..."
End Sub
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 2,224:
 
=={{header|VBScript}}==
<langsyntaxhighlight lang="vb"> s1="Hello"
s2=s1 & " World!"
WScript.Echo s2 </langsyntaxhighlight>
{{out}}
<pre>
Line 2,240:
'''Platform:''' [[.NET]]
{{works with|Visual Basic .NET|9.0+}}
<langsyntaxhighlight lang="vbnet">s = "Hello"
Console.WriteLine(s & " literal")
s1 = s + " literal"
Console.WriteLine(s1)</langsyntaxhighlight>
 
=={{header|Vlang}}==
<langsyntaxhighlight lang="vlang">s := 'hello'
 
println(s)
Line 2,253:
s2:= s+ ' literal'
 
println(s2)</langsyntaxhighlight>
{{out}}
<pre>
Line 2,262:
 
=={{header|Wee Basic}}==
<langsyntaxhighlight Weelang="wee Basicbasic">let string1$="Hello "
let string2$="world!"
print 1 string1$+string2$
end</langsyntaxhighlight>
 
=={{header|Wren}}==
<langsyntaxhighlight lang="javascript">var s = "Hello, "
var t = s + "world!"
System.print(s)
System.print(t)</langsyntaxhighlight>
 
{{out}}
Line 2,280:
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">func Concat(S1, S2, S3); \Concatenate strings: S3:= S1 + S2
char S1, S2, S3;
int C, I, J;
Line 2,302:
Concat(A, B, C);
Text(0, C);
]</langsyntaxhighlight>
 
=={{header|Yorick}}==
<langsyntaxhighlight lang="yorick">var1 = "Hello";
var2 = var1 + ", world!";
write, var1;
write, var2;</langsyntaxhighlight>
 
=={{header|Zig}}==
<langsyntaxhighlight lang="zig">const std = @import("std");
 
const debug = std.debug;
Line 2,341:
 
debug.warn("{}\n", .{hello_world_joined});
}</langsyntaxhighlight>
 
{{out}}
Line 2,352:
 
=={{header|zkl}}==
<langsyntaxhighlight lang="zkl">var s="Hello";
s2:=s+", world!"; s2.println(); //-->Hello, world!
s3:=String(s," ",s2); s3.println(); //-->Hello Hello, world!</langsyntaxhighlight>
 
 
Line 2,362:
 
=={{header|Zoea}}==
<syntaxhighlight lang="zoea">
<lang Zoea>
program: string_concat
input: ['hello', 'literal']
output: 'hello literal'
</syntaxhighlight>
</lang>
 
=={{header|Zoea Visual}}==
10,333

edits