let extra = "little" in
Printf.printf "Mary had a %s lamb." extra


main: func {
  X := "little"
  "Mary had a #{X} lamb" println()
}


declare
  X = "little"
in
  {System.showInfo "Mary had a "#X#" lamb"}


S = "hello",
S1 = S ++ " literal",
io:format ("~s literal~n",[S]),
io:format ("~s~n",[S1])


sequence s, s1
s = "hello"
puts(1, s & " literal")
puts(1,'\n')
s1 = s & " literal"
print (1, s1))
puts(1,'\n')


GEN
string_interpolate(GEN n)
{
  pari_printf("The value was: %Ps.\n", n);
  GEN s = pari_sprintf("Storing %Ps in a string", n);
}


$extra = "little";
print "Mary had a $extra lamb.\n";
printf "Mary had a %s lamb.\n", $extra;


string size = "little"
string s = sprintf("Mary had a %s lamb.",{size})
?s


<?php
$extra = 'little';
echo "Mary had a $extra lamb.\n";
printf("Mary had a %s lamb.\n", $extra);
?>


main =>
  V = "little",
  printf("Mary had a %w lamb\n", V),

  % As a function
  S = to_fstring("Mary had a %w lamb", V),
  println(S).


open System

[<EntryPoint>]
let main args =
    let s = "hello"
    Console.Write(s)
    Console.WriteLine(" literal")
    let s2 = s + " literal"
    Console.WriteLine(s2)
    0


"wake up" [ " sheeple" append print ] [ ", you sheep" append ] bi print


/* created by Aykayayciti Earl Lamont Montgomery
April 9th, 2018 */

s = "critical"
> s + " literal"
s2 = s + " literal"
> s2


fansh> a := "abc"
abc
fansh> b := a + "def"
abcdef
fansh> a
abc
fansh> b
abcdef


(let Extra "little"
   (prinl (text "Mary had a @1 lamb." Extra)) )


*process or(!) source xref attributes;
 sit: Proc Options(main);
 /*********************************************************************
 * Test string replacement
 * 02.08.2013 Walter Pachl
 *********************************************************************/
 Dcl s Char(50) Var Init('Mary had a &X lamb. It is &X');
 Put Edit(repl(s,'little','&X'))(Skip,A);

 repl: Proc(str,new,old) Returns(Char(50) Var);
 /*********************************************************************
 * ooREXX has CHANGESTR(old,str,new[,count])
 * repl follows, however, the translate "philosophy"
 * translate(str,new,old) when old and new are just  a character each
 * and replaces all occurrences of old in str by new
 *********************************************************************/
 Dcl str Char(*) Var;
 Dcl (new,old) Char(*);
 Dcl (res,tmp) Char(50) Var init('');
 Dcl p Bin Fixed(31);
 tmp=str;                             /* copy the input string       */
 Do Until(p=0);
   p=index(tmp,old);                  /* position of old in tmp      */
   If p>0 Then Do;                    /* found                       */
     res=res!!left(tmp,p-1)!!new;     /* append new to current result*/
     tmp=substr(tmp,p+length(old));   /* prepare rest of input       */
     End;
   End;
 res=res!!tmp;                        /* final append                */
 Return(res);
 End;
 End;


$extra = "little"
"Mary had a {0} lamb." -f $extra


Extra = little,
format('Mary had a ~w lamb.', [Extra]),  % display result
format(atom(Atom), 'Mary had a ~w lamb.', [Extra]).  % ... or store it a variable


s" hello" pad place
pad count type
s"  there!" pad +place    \ +place is called "append" on some Forths
pad count type


program StringConcatenation

integer, parameter          :: maxstringlength = 64
character (maxstringlength) :: s1, s = "hello"

print *,s // " literal"
s1 = trim(s) // " literal"
print *,s1

end program


' FB 1.05.0 Win64

Var s1 = "String"
Var s2 = s1 + " concatenation"
Print s1
Print s2
Sleep


a = "Frink"
b = a + " rules!"
println[b]


ReplaceString("Mary had a X lamb.","X","little")


>>> original = 'Mary had a %s lamb.'
>>> extra = 'little'
>>> original % extra
'Mary had a little lamb.'


DefStr S

' Qbasic /QuickBasic MID$ statement needs that string2 and substring
' to replace in string1 must have the same length,
' otherwise it overwrites the following part of string1
String1 = "Mary has a X lamb"
Print String1, "Original String1"
Print "Interpolation of string by MID$ statement"
String2 = "little"
Mid$(String1, InStr(String1, "X")) = String2
Print String1

String1 = "Mary has a X lamb"
String2 = "@"
Mid$(String1, InStr(String1, "X")) = String2
Print String1

Print "Interpolation by string's functions"
String1 = "Mary has a X lamb"
String2 = "little"
String1 = Mid$(String1, 1, InStr(String1, "X") - 1) + String2 + Mid$(String1, InStr(String1, "X") + 1, Len(String1) - InStr(String1, "X"))
Print String1, "by MID$"

String1 = "Mary has a X lamb"
String2 = "#§[]@"
String1 = Left$(String1, InStr(String1, "X") - 1) + String2 + Right$(String1, Len(String1) - InStr(String1, "X") + 1)
Print String1, "by LEFT$ and RIGHT$"


#lang racket

(format "Mary had a ~a lamb" "little")


my $extra = "little";
say "Mary had a $extra lamb";           # variable interpolation
say "Mary had a { $extra } lamb";       # expression interpolation
printf "Mary had a %s lamb.\n", $extra; # standard printf
say $extra.fmt("Mary had a %s lamb");   # inside-out printf
my @lambs = <Jimmy Bobby Tommy>;
say Q :array { $$$ The lambs are called @lambs[]\\\.} # only @-sigiled containers are interpolated


str: "Mary had a <%size%> lamb"
size: "little"
build-markup str

;REBOL3 also has the REWORD function
str: "Mary had a $size lamb"
reword str [size "little"]


window 1

CFStringRef s1, s2

s1 = @"any text value "
print s1

s2 = fn StringByAppendingString( s1, @"another string literal" )
print s2

HandleEvents


Public sub main()
DIM bestclub AS String
DIM myconcat AS String

bestclub = "Liverpool"
myconcat = bestclub & " Football Club"

Print myconcat

End


package main

import "fmt"

func main() {
    // text assigned to a string variable
    s := "hello"

    // output string variable
    fmt.Println(s)

    // this output requested by original task descrption, although
    // not really required by current wording of task description.
    fmt.Println(s + " literal")

    // concatenate variable and literal, assign result to another string variable
    s2 := s + " literal"

    // output second string variable
    fmt.Println(s2)
}


/*REXX program to demonstrate string interpolation (string replacement).*/
                                       /*the string to be replaced is   */
replace   = "little"                   /*usually a unique character(s)  */
                                       /*string and is  case  sensative.*/
original1 = "Mary had a X lamb."
new1      = changestr('X', original1, replace)
say 'original1 =' original1
say 'replaced  =' new1
say

original2 = "Mary had a % lamb."
new2      = changestr('%', original2, replace)
say 'original2 =' original2
say 'replaced  =' new2
say

original3 = "Mary had a $$$ lamb."
new3      = changestr('$$$',original3,replace)
say 'original3 =' original3
say 'replaced3 =' new3
say

original4 = "Mary had a someKindOf lamb."
new3      = changestr('someKindOf', original4, "little")
say 'original4 =' original4
say 'replaced4 =' new3
                                       /*stick a fork in it, we're done.*/


aString =substr("Mary had a X lamb.", "X", "little")
see aString + nl


irb(main):001:0> extra = 'little'
=> "little"
irb(main):002:0> "Mary had a #{extra} lamb."
=> "Mary had a little lamb."
irb(main):003:0> "Mary had a %s lamb." % extra
=> "Mary had a little lamb."


"a$ = Mary had a X lamb."
a$ = word$(a$,1,"X")+"little"+word$(a$,2,"X")
print a$


fn main() {
    println!("Mary had a {} lamb", "little");
    // You can specify order
    println!("{1} had a {0} lamb", "little", "Mary");
    // Or named arguments if you prefer
    println!("{name} had a {adj} lamb", adj="little", name="Mary");
}


object StringInterpolation extends App {

  import util.matching.Regex._
  val size = "little"

  { // Method I (preferred)
    // Scala 2.10.0 supports direct string interpolation
    // by putting "s" at the beginning of the string.
    println("V2.10+  : " + s"Mary had a $size lamb,")
  }

  { // Method II
    // Pre Scala 2.10 indirect use of Java Class Formatter
    val originalFormatter = "Mary had a %s lamb,"
    println("V2.10- 1: " + originalFormatter format size)
    // Above mentioned is Scala's postfix notation and equivalent for:
    println("V2.10- 2: " + originalFormatter.format(size))
    // Also possible
    printf(("V2.10- 3: " + originalFormatter + '\n').format(size))
    // All will be expanded to
    print(("V2.10- 3: " + originalFormatter + '\n').format(size))
    print((new java.util.Formatter).format("V2.10- 4: " + originalFormatter + '\n', size))
  }

  { // Method III
    // Regular expressions, only for demonstration
    val extractor = """\$\{([^}]+)\}""".r
    println((extractor.replaceAllIn("Regex  1: Mary had a ${x} lamb,", "snow white")))

    // RegEx freaking
    def interpolate(text: String, vars: (String, String)*) =
      extractor.replaceAllIn(text,
        _ match { case Groups(v) => vars.toMap.getOrElse(v, "" /*in case nothing provided*/ ) })

    println(interpolate("Regex  2: ${who} had a ${size} ${pet}, ${unknown}",
      ("pet", "lamb"), ("size", "fat"), ("size", "humongous"), ("who", "Mary")))
  }

  { // Method IV, not recommended.
    // Standard API method, search argument (1st ones) supposed to be a regular expression
    println("Replace1: " + "Mary had a ${x} lamb".replaceAll("""\$\{x\}""", size))
    // Standard API method, literally, on regular expression
    println("Replace2: " + "Mary had a ${x} lamb".replaceAllLiterally("${x}", size))
  }

  { // Method IV, not recommended.
    println("Split   : " + "Mary had a ${x} lamb.".split("""\$\{([^}]+)\}""").mkString(size))
  }
}


"Greetings ":s;
s"Earthlings"+puts
s"Earthlings"+:s1;
s1 puts


def s = "Greetings "
println s + "Earthlings"

def s1 = s + "Earthlings"
println s1


import System.IO
s = "hello"
s1 = s ++ " literal"
main = do putStrLn (s ++ " literal")
          putStrLn s1


#!/bin/bash
# Usage example: . interpolate "Mary has a X lamb" "quite annoying"
echo "$1" | sed "s/ X / $2 /g"


$ include "seed7_05.s7i";

const proc: main is func
  local
    const string: original is "Mary had a X lamb";
    const string: little is "little";
    var string: replaced is "";
  begin
    replaced := replace(original, "X", little);
    writeln(replaced);
  end func;


put "little" into x

put "Mary had a [[x]] lamb." -- this is a literal string
put !"Mary had a [[x]] lamb." -- this is an interpolated string
put
put !"[[repeat with n=2 to 6]]Mary had [[n]] [[x]] lambs.[[return]][[end repeat]]"
put !"Mary had [[repeat with n=2 to 6]][[n]] [[x]] [[end repeat]]lambs."


var extra = 'little';
say "Mary had a #{extra} lamb";


        s1 = "Mary had a humongous lamb."
	s2 = "humongous"
        s3 = "little"
	s1 s2 = s3
end


: printf("Mary had a %s lamb.\n", "little")
Mary had a little lamb.


let extra = "little"
println("Mary had a \(extra) lamb.")


CHARACTER s = "hello", sl*100

WRITE() s // " literal"
sl = s // " literal"
WRITE() sl


procedure main()
s1 := "hello"
write(s2 := s1 || " there.")  # capture the reuslt for
write(s2)                     # ... the 2nd write
end


s1='Hello'
print, s1 + ' literal'
s2=s1 + ' literal'
print, s2


   s1 =. 'Some '
   ]s1, 'text '
Some text
   ]s2 =. s1 , 'more text!'
Some more text!


def size: 'little';
'Mary had a $size; lamb' -> !OUT::write


set size "little"
puts "Mary had a $size lamb."

proc RandomWord {args} {
   lindex $args [expr {int(rand()*[llength $args])}]
}
puts "Mary had a [RandomWord little big] lamb."


$$ MODE TUSCRIPT

sentence_old="Mary had a X lamb."

values=*
DATA little
DATA big

sentence_new=SUBSTITUTE (sentence_old,":X:",0,0,values)
PRINT sentence_old
PRINT sentence_new


extra='little'
echo Mary had a $extra lamb.
echo "Mary had a $extra lamb."
printf "Mary had a %s lamb.\n" $extra


void main() {
  string size = "little";
  print(@"Mary had a $size lamb\n");
  stdout.printf("Mary had a %s lamb\n", size);
}


a="little"
debug.print replace("Mary had a X lamb","X",a)  'prints Mary had a little lamb


public class Str{
   public static void main(String[] args){
      String s = "hello";
      System.out.println(s + " literal");
      String s2 = s + " literal";
      System.out.println(s2);
   }
}


s1: "Some "
s1, "text "
s2: s1 , "more text!"


////////////////////////////////////////////////////////////////////////////////////////
//
//  The @INTERPOLATE verb processes a string with imbedded blocks of code.  The code
//  blocks are parsed and evaluated.  Any results are converted to a string, which
//  is then inserted into the output string, replacing the code and braces.
//
// example: @INTERPOLATE "text{ @IF (x > y) then:{x} else:{y} }more text "
//
////////////////////////////////////////////////////////////////////////////////////////

@VAR v = "little";

@SAY (@INTERPOLATE "Mary had a { v } lamb");

//   output:    Mary had a litle lamb


Dim name as String = "J. Doe"
Dim balance as Double = 123.45
Dim prompt as String = String.Format("Hello {0}, your balance is {1}.", name, balance)
Console.WriteLine(prompt)


var s = "little"
var t = "Mary had a %(s) lamb"
System.print(t)


txt := "little"
str := "Mary had a $txt lamb"
println(str)


char X;
[X:= "little";
Text(0, "Mary had a ");  Text(0, X);  Text(0, " lamb.");
]


fun main(args: Array<String>) {
    val s1 = "James"
    val s2 = "Bond"
    println(s1)
    println(s2)
    val s3 = s1 + " " + s2
    println(s3)
}


{def christian_name Albert}
-> christian_name
{def name de Jeumont-Schneidre}
-> name

{christian_name} {name}
-> Albert de Jeumont-Schneidre


: concat  2 compress "" join ;
'hello " literal" concat


local(x = 'Hello')
local(y = #x + ', World!')
#x // Hello
#y // Hello, World!


a = "Hello"
b = a & " world!"
put b
-- "Hello world!"


Section Header

+ name := STRING_CONCATENATION;

Section Public

- main <- (
  + sc : STRING_CONSTANT;
  + sv : STRING;

  sc := "Hello";
  (sc + " literal").println;

  sv := sc + " literal";
  sv.println;

);


local str="live"
put str & "code" into str2
put str && str2


a = "hello "
print(a .. "world")
c = a .. "world"
print(c)


Module CheckString {
      s$ = "hello"
      PRINT s$;" literal" 'or s$ + " literal"
      s2$ = s$ + " literal"
      PRINT s2$
      Print Len(s2$)=13
      \\ get an ansi string
      k$=Str$("Hello")
      Print Len(k$)=2.5  ' 2.5 words or 5 bytes
      Print Chr$(k$)
      k2$=k$+Str$(" literal")
      Print Len(k2$)=6.5  ' 13 bytes
      Print Chr$(k2$)
      Print Len(Chr$(k2$))=13 ' words
}
CheckString


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


str := "Hello":
newstr := cat(str,", world!"):
str;
newstr;


Carpenter := "Gort. " (Carpenter = "Gort. ")


>> string1 = '1 Fish'

string1 =

1 Fish

>> string2 = [string1 ', 2 Fish, Red Fish, Blue Fish']

string2 =

1 Fish, 2 Fish, Red Fish, Blue Fish


s: "the quick brown fox";
t: "jumps over the lazy dog";
sconcat(s, " ", t);
/* "the quick brown fox jumps over the lazy dog" */


s = "hello"
print (s + " literal")
s1 = s + " literal"
print s1


:- module string_concat.
:- interface.

:- import_module io.
:- pred main(io::di, io::uo) is det.

:- implementation.
:- import_module string.

main(!IO) :-
    S = "hello",
    S1 = S ++ " world",
    io.write_string(S, !IO), io.nl(!IO),
    io.write_string(S1, !IO), io.nl(!IO).


string a, b;
a := "String";
message a & " literal";
b := a & " literal";
message b;


"butter" :a
(a "scotch")=> "" join :b
a puts!
b puts!


MODULE Concat EXPORTS Main;

IMPORT IO;

VAR string: TEXT := "String";
    string1: TEXT;

BEGIN
  IO.Put(string & " literal.\n");
  string1 := string & " literal.\n";
  IO.Put(string1);
END Concat.


STRCAT
 SET S="STRING"
 WRITE !,S
 SET T=S_" LITERAL"
 WRITE !,T
 QUIT


s1 = "hello"
println s1 + " world"

s2 = s1 + " world"
println s2


/**
 String concatenation, in Neko
 Tectonics:
    nekoc string-concatenation.neko
    neko string-concatenation [addon]
*/

var arg = $loader.args[0]
var addon
if arg != null addon = $string(arg)

var s = "abc"
$print("s: ", s, "\n")

var c = s + "def"
$print("c: ", c, "\n")

if arg != null {
    c += addon
    $print("addon: ", addon, "\n")
    $print("c: ", c, "\n")
}


using System;
using System.Console;
using Nemerle.Utility.NString; // contains method Concat()

module Stringcat
{
    Main() : void
    {
        def text1 = "This string has";
        def cat1  = Concat( " ", [text, "been concatenated"]);
        def cat2  = text1 + " also been concatenated";
        Write($"$cat1\n$cat2\n");
    }
}


/* NetRexx */

options replace format comments java crossref savelog symbols

s1 = 'any text value'
s2 = 'another string literal'
s3 = s1    s2 -- concatenate variables with blank space (note that only one blank space is added)
s4 = s1 || s2 -- concatenate variables with abuttal (here, no blank spaces are added)
s5 = s1    'another string literal' -- concatenate a variable and a literal with blank space
s6 = s1'another string literal'     -- concatenate a variable and a literal using abuttal
s7 = s1 || 'another string literal' -- ditto

say 's1:' s1 -- concatenation with blank space is employed here too
say 's2:' s2
say 's3:' s3
say 's4:' s4
say 's5:' s5
say 's6:' s6
say 's7:' s7


(let (str1 "foo")
     (println str1)
     (let (str2 (string str1 "bar"))
	  (println str2)))


let str = "String"
echo str & " literal."

# -> String literal.


10 STRING$="HELLO"
20 STRING$=STRING$+" WORLD!"
30 PRINT STRING$


bundle Default {
  class Repeat {
    function : Main(args : String[]) ~ Nil {
      s := "hello";
      s->PrintLine();
      " literal"->PrintLine();
      s->Append(" literal");
      s->PrintLine();
    }
  }
}


#import <Foundation/Foundation.h>

int main()
{
  @autoreleasepool {

    NSString *s = @"hello";
    printf("%s%s\n", [s UTF8String], " literal");

    NSString *s2 = [s stringByAppendingString:@" literal"];
    // or, NSString *s2 = [NSString stringWithFormat:@"%@%@", s, @" literal"];
    puts([s2 UTF8String]);
    /* or */
    NSMutableString *s3 = [NSMutableString stringWithString: s];
    [s3 appendString: @" literal"];
    puts([s3 UTF8String]);

  }
  return 0;
}


let s = "hello"
let s1 = s ^ " literal"
let () =
  print_endline (s ^ " literal");
  print_endline s1


a="straw";
b="berry";
c=str(a,b);    /* Concatenate a and b */
echo (c);


declare
S = "hello"
{System.showInfo S#" literal"} %% virtual strings are constructed with "#"
S1 = {Append S " literal"}
{System.showInfo S1}


s = "Hello ";
s = Str(s, "world");
\\ Alternately, this could have been:
\\ s = concat(s, "world");
print(s);


Program StringConcat;
  Var
     s, s1   : String;

Begin
    s := 'hello';
    writeln(s + ' literal');
    s1 := concat(s, ' literal');
    { s1 := s + ' literal'; works too, with FreePascal }
    writeln(s1);
End.


my $s = 'hello';
print $s . ' literal', "\n";
my $s1 = $s . ' literal';
print $s1, "\n";


string s1 = "at"                                ?s1
string s2 = "c"&s1                              ?s2
string s3 = "s"&s1                              ?s3
string s4 = "m"&s1                              ?s4
string s5 = "The "&s2&" "&s3&" on the "&s4&"."  ?s5


module stringcat;

extern printf;

@Integer main [
    var a = "hello";
    var b = a + " literal";
    printf("%s\n", b);

    return 0;
]


<?php
$s = "hello";
echo $s . " literal" . "\n";
$s1 = $s . " literal";
echo $s1 . "\n";
?>


main =>
  Hello = "Hello, ",
  print(Hello ++ "world!" ++ "\n"),
  String = Hello ++ "world!",
  String := String ++ "\n",
  print(String).


(let Str1 "First text"
   (prinl Str1 " literal")
   (let Str2 (pack Str1 " literal")
      (prinl Str2) ) )


string hello = "hello ";
write(hello + "world" + "\n");
string all_of_it = hello + "world";
write(all_of_it + "\n");


declare (s, t) character (30) varying;

s = 'hello from me';
display (s || ' to you.' );
t = s || ' to you all';
display (t);


To run:
Start up.
Put "hello" into a string.
Put the string then " world" into another string.
Write the string to the console.
Write the other string to the console.
Wait for the escape key.
Shut down.


$s = "Hello"
Write-Host $s World.

# alternative, using variable expansion in strings
Write-Host "$s World."

$s2 = $s + " World."
Write-Host $s2


If OpenConsole()

  s$ = "hello"
  PrintN( s$ + " literal")
  s2$ = s$ + " literal"
  PrintN(s2$)

  Print(#CRLF$ + #CRLF$ + "Press ENTER to exit")
  Input()
  CloseConsole()
EndIf


s1 = "hello"
print s1 + " world"

s2 = s1 + " world"
print s2


s1$ = "String"
s2$ = s1$ + " concatenation"
PRINT s1$
PRINT s2$


  $ "A duck's quack"
  $ " has no echo."
  join
  echo$


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"


#lang racket
(define hello "hello")
(displayln hello)

(define world (string-append hello " " "world" "!"))
(displayln world)

;outputs:
;  hello
;  hello world!


my $s = 'hello';
say $s ~ ' literal';
my $s1 = $s ~ ' literal';
say $s1;

# or, using mutating concatenation:

$s ~= ' literal';
say $s;


# Cat strings
"First string and " "second string" cat print

# Join
[ "First string" "second string" "third string" ] " and " join print

# print
[ "First string" "second string" "third string" ] each print

# Formatted print
"\n" "Third string" "Second string" "First string" "%s %s %s %s" print

# Heredoc
" - NOT!!" as $x
"This is the only way to do it%($x)s" print


s: "hello"
print s1: rejoin [s " literal"]
print s1


>>str1: "Hello"
>>str2: append str1 " World"
>> print str2
Hello World
>> print str1
Hello World


let s1 = "hello"
let s2 = s1 ++ " literal"

Js.log(s1)
Js.log(s2)


s = "hello"
say s "literal"
t = s "literal"         /*whitespace between the two strings causes a space in the output.*/
say t
                        /*the above method works without spaces too.*/

genus= "straw"
say genus"berry"        /*this outputs strawberry.*/
say genus || "berry"    /*concatenation using a double-pipe does not cause spaces.*/


aString = "Welcome to the "
bString = "Ring Programming Language"

see astring + bString + nl


s = "hello"

puts "#{s} template"       #=> "hello template"
# Variable s is intact
puts s                     #=> "hello"

puts s + " literal"        #=> "hello literal"
# Variable s is still the same
puts s                     #=> "hello"

# Mutating s variable:

s += " literal"
puts s                     #=> "hello literal"
s << " another" # append to s, use only when string literals are not frozen
puts s                     #=> "hello literal another"

s = "hello"
puts s.concat(" literal")  #=> "hello literal"
puts s                     #=> "hello literal"
puts s.prepend("Alice said: ")  #=> "Alice said: hello literal"
puts s                     #=> "Alice said: hello literal"


fn main() {
    let s = "hello".to_owned();
    println!("{}", s);

    let s1 = s + " world";
    println!("{}", s1);
}


data _null_;
   a="Hello,";
   b="World!";
   c=a !! " " !! b;
   put c;
   *Alternative using the catx function;
   c=catx (" ", a, b);
   put c;
run;


class MAIN is
  main is
    s ::= "hello";
    #OUT + s + " literal\n";
    s2 ::= s + " literal";
    #OUT + s2 + "\n";
  end;
end;


rem - the + operator is used to concatenate strings

var s1, s2 = string

s1 = "Hello"
print s1 + ", world"

s2 = s1 + ", world"
print s2

end


  val s = "hello"                                 //> s  : String = hello
  val s2 = s + " world"                           //> s2  : String = hello world
  val f2 = () =>  " !"                            //> f2  : () => String = <function0>

  println(s2 + f2())                              //> hello world !


(define s "hello")
(display (string-append s " literal"))
(newline)
(define s1 (string-append s " literal"))
(display s1)
(newline)


s1="Hello"
s1+" world!"
s2=s1+" world"
s2


$ include "seed7_05.s7i";

const proc: main is func
  local
    var string: s is "hello";
    var string: s2 is "";
  begin
    writeln(s <& " world");
    s2 := s & " world";
    writeln(s2);
  end func;


var s = 'hello';
say s+' literal';
var s1 = s+' literal';
say s1;


TEXT PROCEDURE concatenate(head, tail);
    TEXT head, tail;
BEGIN TEXT c;
    c :- blanks(head.length + tail.length);
    c.sub(c.start, head.length) := head; ! putText(), anyone?;
    c.sub(c.start + head.length, tail.length) := tail;
    concatenate:- c;
END;

TEXT stringVariable, another;
stringVariable :- "head ";
another :- concatenate(stringVariable, "and tail");
OutText("stringVariable: """); OutText(stringVariable);
OutText(""", another: "); OutText(another); Outimage;


define: #s -> 'hello'.
inform: s ; ' literal'.
define: #s1 -> (s ; ' literal').
inform: s1.


|s s1| s := 'hello'.
(s,' literal') printNl.
s1 := s,' literal'.
s1 printNl.


	greet1 = "Hello, "
	output = greet1
	greet2 = greet1 "World!"
	output = greet2
end


let s1 = "Hello";
let s2 = " world!";
print(s1 .. s2); // prints "Hello world!"


val s = "hello"
val s1 = s ^ " literal\n"
val () =
  print (s ^ " literal\n");
  print s1


sca a = "foo"
sca b = "bar"
sca c = a+b
di c
  foobar


let s = "hello"
println(s + " literal")
let s1 = s + " literal"
println(s1)


| concatenate a string

 'The quick brown fox ' $s
 + 'jumped over the lazy moon.' $s
 $s []


def a: 'Hello';
'$a;, World!' -> !OUT::write


set s hello
puts "$s there!"
append s " there!"
puts $s


"aard" → sv
Disp sv & "vark"
sv & "wolf" → sv2


%string = "Hello";
echo(%string);
%other = " world!";
echo(%other);
echo(%string @ %other);


$$ MODE TUSCRIPT
s = "Hello "
print s, "literal"

s1 = CONCAT (s,"literal")
print s1


s="hello"
echo "$s literal"
s1="$s literal"    # This method only works with a space between the strings
echo $s1

# To concatenate without the space we need squiggly brackets:
genus='straw'
fruit=${genus}berry  # This outputs the word strawberry
echo $fruit


echo "hello"
 | xargs -n1 -i echo {} literal


decl string s1 s2
# make s1 contain "hello "
set s1 "hello "

# set s2 to contain s1 and "world"
set s2 (+ s1 "world")

# outputs "hello world"
out s2 endl console


void main() {
  var s = "hello";
  print(s);
  print(" literal\n");
  var s2 = s + " literal\n";
  print(s2);
}


Option Explicit

Sub String_Concatenation()
Dim str1 As String, str2 As String

    str1 = "Rosetta"
    Debug.Print str1
    Debug.Print str1 & " code!"
    str2 = str1 & " code..."
    Debug.Print str2 & " based on concatenation of : " & str1 & " and code..."
End Sub


	s1="Hello"
	s2=s1 & " World!"
	WScript.Echo s2


s = "Hello"
Console.WriteLine(s & " literal")
s1 = s + " literal"
Console.WriteLine(s1)


s := 'hello'

println(s)
println(s+' literal')

s2:= s+ ' literal'

println(s2)


let string1$="Hello "
let string2$="world!"
print 1 string1$+string2$
end


var s = "Hello, "
var t = s + "world!"
System.print(s)
System.print(t)


func Concat(S1, S2, S3);        \Concatenate strings: S3:= S1 + S2
char S1, S2, S3;
int  C, I, J;
[I:= 0;
repeat  C:= S1(I);
        S3(I):= C & $7F;        \remove MSb terminator from first string
        I:= I+1;
until   C >= $80;
J:= 0;
repeat  C:= S2(J);
        S3(I+J):= C;
        J:= J+1;
until   C >= $80;
return S3;
];

code Text=12;
char A, B, C(80);
[A:= "Hello";
 B:= " World!";
Concat(A, B, C);
Text(0, C);
]


var1 = "Hello";
var2 = var1 + ", world!";
write, var1;
write, var2;


const std = @import("std");

const debug = std.debug;
const heap = std.heap;
const mem = std.mem;

test "string concatenation" {
    const hello = "Hello,";

    debug.warn("\n{}{}\n", .{ hello, " world!" });

    // Method 1: Array concatenation
    //
    // This only works if the values are known at compile-time.
    const hello_world_at_comptime = hello ++ " world!";

    debug.warn("{}\n", .{hello_world_at_comptime});

    // Method 2: std.mem.concat
    var buf: [128]u8 = undefined;
    const allocator = &heap.FixedBufferAllocator.init(&buf).allocator;

    const hello_world_concatenated = try mem.concat(allocator, u8, &[_][]const u8{ hello, " world!" });

    debug.warn("{}\n", .{hello_world_concatenated});

    // Method 3: std.mem.join
    const hello_world_joined = try mem.join(allocator, " ", &[_][]const u8{ hello, "world!" });

    debug.warn("{}\n", .{hello_world_joined});
}


var s="Hello";
s2:=s+", world!"; s2.println(); //-->Hello, world!
s3:=String(s," ",s2); s3.println(); //-->Hello Hello, world!


program: string_concat
  input: ['hello', 'literal']
  output: 'hello literal'


F compare(a, b)
   I a <  b {print(‘'#.' is strictly less than  '#.'’.format(a, b))}
   I a <= b {print(‘'#.' is less than or equal to '#.'’.format(a, b))}
   I a >  b {print(‘'#.' is strictly greater than  '#.'’.format(a, b))}
   I a >= b {print(‘'#.' is greater than or equal to '#.'’.format(a, b))}
   I a == b {print(‘'#.' is equal to '#.'’.format(a, b))}
   I a != b {print(‘'#.' is not equal to '#.'’.format(a, b))}

compare(‘YUP’, ‘YUP’)
compare(‘BALL’, ‘BELL’)
compare(‘24’, ‘123’)


/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program comparString64.s   */

/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
/*******************************************/
/* Initialized data                        */
/*******************************************/
.data
szMessStringEqu:    .asciz "The strings are equals.\n"
szMessStringNotEqu: .asciz "The strings are not equals.\n"
szCarriageReturn:   .asciz "\n"

szString1:          .asciz "ABCDE"
szString2:          .asciz "ABCDE"
szString3:          .asciz "ABCFG"
szString4:          .asciz "ABC"
szString5:          .asciz "abcde"
/*******************************************/
/* UnInitialized data                       /
/*******************************************/
.bss
/*******************************************/
/*  code section */
/*******************************************/
.text
.global main
main:                         // entry of program

    ldr x0,qAdrszString1
    ldr x1,qAdrszString2
    bl Comparaison

    ldr x0,qAdrszString1
    ldr x1,qAdrszString3
    bl Comparaison

    ldr x0,qAdrszString1
    ldr x1,qAdrszString4
    bl Comparaison
                             // case sensitive comparisons ABCDE et abcde
    ldr x0,qAdrszString1
    ldr x1,qAdrszString5
    bl Comparaison
                             // case insensitive comparisons  ABCDE et abcde
    ldr x0,qAdrszString1
    ldr x1,qAdrszString5
    bl comparStringsInsensitive
    cbnz x0,1f
    ldr x0,qAdrszMessStringEqu
    bl affichageMess
    b 2f
1:
    ldr x0,qAdrszMessStringNotEqu
    bl affichageMess

2:

100:                             // standard end of the program
    mov x0,0                     // return code
    mov x8,EXIT                  // request to exit program
    svc 0                        // perform the system call
qAdrszString1:           .quad szString1
qAdrszString2:           .quad szString2
qAdrszString3:           .quad szString3
qAdrszString4:           .quad szString4
qAdrszString5:           .quad szString5
qAdrszMessStringEqu:     .quad szMessStringEqu
qAdrszMessStringNotEqu:  .quad szMessStringNotEqu
qAdrszCarriageReturn:    .quad  szCarriageReturn
/*********************************************/
/* comparaison                               */
/*********************************************/
/* x0 contains address String 1           */
/* x1 contains address String 2         */
Comparaison:
    stp x1,lr,[sp,-16]!            // save  registers
    bl comparStrings
    cbnz x0,1f
    ldr x0,qAdrszMessStringEqu
    bl affichageMess
    b 2f
1:
    ldr x0,qAdrszMessStringNotEqu
    bl affichageMess

2:
    ldp x1,lr,[sp],16              // restaur  2 registers
    ret                            // return to address lr x30

/************************************/
/* Strings case sensitive comparisons  */
/************************************/
/* x0 et x1 contains the address of strings */
/* return 0 in x0 if equals */
/* return -1 if string x0 < string x1 */
/* return 1  if string x0 > string x1 */
comparStrings:
    stp x1,lr,[sp,-16]!    // save  registers
    stp x2,x3,[sp,-16]!    // save  registers
    stp x4,x5,[sp,-16]!    // save  registers
    mov x2,#0              // counter
1:
    ldrb w3,[x0,x2]        // byte string 1
    ldrb w4,[x1,x2]        // byte string 2
    cmp x3,x4
    blt 2f
    bgt 3f
    cbz x3,4f              // 0 end string
    add x2,x2,1            // else add 1 in counter
    b 1b                   // and loop */
2:
    mov x0,-1              // lower
    b 100f
3:
    mov x0,1               // higher
    b 100f
4:
    mov x0,0               // equal
100:
    ldp x4,x5,[sp],16      // restaur  2 registers
    ldp x2,x3,[sp],16      // restaur  2 registers
    ldp x1,lr,[sp],16      // restaur  2 registers
    ret                    // return to address lr x30
/************************************/
/* Strings case insensitive comparisons    */
/************************************/
/* x0 et x1 contains the address of strings */
/* return 0 in x0 if equals */
/* return -1 if string x0 < string x1 */
/* return 1  if string x0 > string x1 */
comparStringsInsensitive:
    stp x1,lr,[sp,-16]!    // save  registers
    stp x2,x3,[sp,-16]!    // save  registers
    stp x4,x5,[sp,-16]!    // save  registers
    mov x2,#0              // counter

1:
    ldrb w3,[x0,x2]        // byte string 1
    ldrb w4,[x1,x2]        // byte string 2
                           // majuscules --> minuscules  byte 1
    cmp x3,65
    blt 2f
    cmp x3,90
    bgt 2f
    add x3,x3,32
2:                         // majuscules --> minuscules  byte 2
    cmp x4,65
    blt 3f
    cmp x4,90
    bgt 3f
    add x4,x4,32
3:
    cmp x3,x4
    blt 4f
    bgt 5f
    cbz x3,6f              // 0 end string
    add x2,x2,1            // else add 1 in counter
    b 1b                   // and loop
4:
    mov x0,-1              // lower
    b 100f
5:
    mov x0,1               // higher
    b 100f
6:
    mov x0,0               // equal
100:
    ldp x4,x5,[sp],16      // restaur  2 registers
    ldp x2,x3,[sp],16      // restaur  2 registers
    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"


PROC TestEqual(CHAR ARRAY s1,s2)
  INT res

  PrintF("""%S"" and ""%S"" are equal: ",s1,s2)
  IF SCompare(s1,s2)=0 THEN
    PrintE("True")
  ELSE
    PrintE("False")
  FI
RETURN

PROC TestInequal(CHAR ARRAY s1,s2)
  INT res

  PrintF("""%S"" and ""%S"" are inequal: ",s1,s2)
  IF SCompare(s1,s2)#0 THEN
    PrintE("True")
  ELSE
    PrintE("False")
  FI
RETURN

PROC TestBefore(CHAR ARRAY s1,s2)
  INT res

  PrintF("""%S"" is before ""%S"": ",s1,s2)
  IF SCompare(s1,s2)<0 THEN
    PrintE("True")
  ELSE
    PrintE("False")
  FI
RETURN

PROC TestAfter(CHAR ARRAY s1,s2)
  INT res

  PrintF("""%S"" is after ""%S"": ",s1,s2)
  IF SCompare(s1,s2)>0 THEN
    PrintE("True")
  ELSE
    PrintE("False")
  FI
RETURN

PROC TestNumEqual(CHAR ARRAY s1,s2)
  INT v1,v2

  PrintF("""%S"" and ""%S"" are equal: ",s1,s2)
  v1=ValI(s1) v2=ValI(s2)
  IF v1=v2 THEN
    PrintE("True")
  ELSE
    PrintE("False")
  FI
RETURN

PROC TestNumInequal(CHAR ARRAY s1,s2)
  INT v1,v2

  PrintF("""%S"" and ""%S"" are inequal: ",s1,s2)
  v1=ValI(s1) v2=ValI(s2)
  IF v1#v2 THEN
    PrintE("True")
  ELSE
    PrintE("False")
  FI
RETURN

PROC TestNumBefore(CHAR ARRAY s1,s2)
  INT v1,v2

  PrintF("""%S"" is before ""%S"": ",s1,s2)
  v1=ValI(s1) v2=ValI(s2)
  IF v1<v2 THEN
    PrintE("True")
  ELSE
    PrintE("False")
  FI
RETURN

PROC TestNumAfter(CHAR ARRAY s1,s2)
  INT v1,v2

  PrintF("""%S"" is after ""%S"": ",s1,s2)
  v1=ValI(s1) v2=ValI(s2)
  IF v1>v2 THEN
    PrintE("True")
  ELSE
    PrintE("False")
  FI
RETURN

PROC Main()
  PrintE("Lexical comparison:")
  TestEqual("abcd","Abcd")
  TestInequal("abcd","Abcd")
  TestBefore("abcd","Abcd")
  TestAfter("abcd","Abcd")
  PutE()

  PrintE("Numerical comparison:")
  TestNumEqual("1234","99876")
  TestNumInequal("1234","99876")
  TestNumBefore("1234","99876")
  TestNumAfter("1234","99876")
RETURN


with Ada.Text_IO, Ada.Strings.Equal_Case_Insensitive;

procedure String_Compare is

   procedure Print_Comparison (A, B : String) is
   begin
      Ada.Text_IO.Put_Line
         ("""" & A & """ and """ & B & """: " &
          (if A = B then
              "equal, "
           elsif Ada.Strings.Equal_Case_Insensitive (A, B) then
              "case-insensitive-equal, "
           else "not equal at all, ")                   &
          (if A /= B then "/=, "     else "")           &
          (if A <  B then "before, " else "")           &
          (if A >  B then "after, "  else "")           &
          (if A <= B then "<=, "     else "(not <=), ") &
          (if A >= B then ">=. "     else "(not >=)."));
   end Print_Comparison;
begin
   Print_Comparison ("this", "that");
   Print_Comparison ("that", "this");
   Print_Comparison ("THAT", "That");
   Print_Comparison ("this", "This");
   Print_Comparison ("this", "this");
   Print_Comparison ("the", "there");
   Print_Comparison ("there", "the");
end String_Compare;


text s, t;

s = "occidental";
t = "oriental";

# operator case sensitive comparison
o_form("~ vs ~ (==, !=, <, <=, >=, >): ~ ~ ~ ~ ~ ~\n", s, t, s == t, s != t, s < t, s <= t, s >= t, s > t);

s = "Oriental";
t = "oriental";

# case sensitive comparison
o_form("~ vs ~ (==, !=, <, >): ~ ~ ~ ~\n", s, t, !compare(s, t), compare(s, t), compare(s, t) < 0, 0 < compare(s, t));

# case insensitive comparison
o_form("~ vs ~ (==, !=, <, >): ~ ~ ~ ~\n", s, t, !icompare(s, t), icompare(s, t), icompare(s, t) < 0, 0 < icompare(s, t));


STRING a := "abc   ", b := "ABC ";

# when comparing strings, Algol 68 ignores trailing blanks                    #
# so e.g. "a" = "a " is true                                                  #

# test procedure, prints message if condition is TRUE                         #
PROC test = ( BOOL condition, STRING message )VOID:
    IF condition THEN print( ( message, newline ) ) FI;

# equality?                                                                   #
test( a = b, "a = b" );
# inequality?                                                                 #
test( a /= b, "a not = b" );

# lexically ordered before?                                                   #
test( a < b, "a < b" );

# lexically ordered after?                                                    #
test( a > b, "a > b" );

# Algol 68's builtin string comparison operators are case-sensitive.          #
# To perform case insensitive comparisons, procedures or operators            #
# would need to be written                                                    #
# e.g.                                                                        #

# compare two strings, ignoring case                                          #
# Note the "to upper" PROC is an Algol 68G extension                          #
# It could be written in standard Algol 68 (assuming ASCII) as e.g.           #
#    PROC to upper = ( CHAR c )CHAR:                                          #
#         IF c < "a" OR c > "z" THEN c                                        #
#         ELSE REPR ( ( ABS c - ABS "a" ) + ABS "A" ) FI;                     #
PROC caseless comparison = ( STRING a, b )INT:
     BEGIN
         INT a max   = UPB a, b max  = UPB b;
         INT a pos  := LWB a, b pos := LWB b;
         INT result := 0;
         WHILE result = 0
           AND ( a pos <= a max OR b pos <= b max )
         DO
             CHAR a char := to upper( IF a pos <= a max THEN a[ a pos ] ELSE " " FI );
             CHAR b char := to upper( IF b pos <= b max THEN b[ b pos ] ELSE " " FI );
             result := ABS a char - ABS b char;
             a pos +:= 1;
             b pos +:= 1
         OD;
         IF result < 0 THEN -1 ELIF result > 0 THEN 1 ELSE 0 FI
     END ; # caseless comparison #

# compare two strings for equality, ignoring case                             #
PROC equal ignoring case = ( STRING a, b )BOOL: caseless comparison( a, b ) = 0;
# similar procedures for inequality and lexical ording ...                    #

test( equal ignoring case( a, b ), "a = b (ignoring case)" );

# Algol 68 is strongly typed - strings cannot be compared to e.g. integers    #
# unless procedures or operators are written, e.g.                            #
# e.g. OP = = ( STRING a, INT b )BOOL: a = whole( b, 0 );                     #
#      OP = = ( INT a, STRING b )BOOL: b = a;                                 #
# etc.                                                                        #

# Algol 68 also has <= and >= comparison operators for testing for            #
# "lexically before or equal" and "lexically after or equal"                  #
test( a <= b, "a <= b" );
test( a >= b, "a >= b" );

# there are no other forms of string comparison builtin to Algol 68           #


begin
    string(10) a;
    string(12) b;

    a := "abc";
    b := "ABC";

    % when comparing strings, Algol W ignores trailing blanks                 %
    % so e.g. "a" = "a " is true                                              %

    % equality?                                                               %
    if a = b then write( "a = b" );
    % inequality?                                                             %
    if a not = b then write( "a not = b" );

    % lexically ordered before?                                               %
    if a < b then write( "a < b" );

    % lexically ordered after?                                                %
    if a > b then write( "a > b" );

    % Algol W string comparisons are case-sensitive. To perform case          %
    % insensitive comparisons, procedures would need to be written            %
    % e.g. as in the following block (assuming the character set is ASCII)    %
    begin

        % convert a character to upper-case                                   %
        integer procedure toupper( integer value c ) ;
            if c < decode( "a" ) or c > decode( "z" ) then c
            else ( c - decode( "a" ) ) + decode( "A" );

        % compare two strings, ignoring case                                  %
        % note that strings can be at most 256 characters long in Algol W     %
        integer procedure caselessComparison ( string(256) value a, b ) ;
            begin
                integer comparisonResult, pos;
                comparisonResult := pos := 0;
                while pos < 256 and comparisonResult = 0 do begin
                    comparisonResult := toupper( decode( a(pos//1) ) )
                                      - toupper( decode( b(pos//1) ) );
                    pos := pos + 1
                end;
                if      comparisonResult < 0 then -1
                else if comparisonResult > 0 then  1
                else                               0
            end caselessComparison ;

        % compare two strings for equality, ignoring case                     %
        logical procedure equalIgnoringCase ( string(256) value a, b ) ;
            ( caselessComparison( a, b ) = 0 );

        % similar procedures for inequality and lexical ording ...           %

        if equalIgnoringCase( a, b ) then write( "a = b (ignoring case)" )
    end caselessComparison ;

    % Algol W is strongly typed - strings cannot be compared to e.g. integers %
    % e.g. "if a = 23 then ..." would be a syntax error                       %

    % Algol W also has <= and >= comparison operators for testing for         %
    % "lexically before or equal" and "lexically after or equal"              %
    if a <= b then write( "a <= b" );
    if a >= b then write( "a >= b" );

    % there are no other forms of string comparison builtin to Algol W        %

end.


public class Compare
{
	/**
	 * Test in the developer console:
	 * Compare.compare('Hello', 'Hello');
	 * Compare.compare('5', '5.0');
	 * Compare.compare('java', 'Java');
	 * Compare.compare('ĴÃVÁ', 'ĴÃVÁ');
	*/

    public static void compare (String A, String B)
    {
        if (A.equals(B))
            System.debug(A + ' and  ' + B + ' are lexically equal.');
        else
            System.debug(A + ' and  ' + B + ' are not lexically equal.');

        if (A.equalsIgnoreCase(B))
            System.debug(A + ' and  ' + B + ' are case-insensitive lexically equal.');
        else
            System.debug(A + ' and  ' + B + ' are not case-insensitive lexically equal.');

        if (A.compareTo(B) < 0)
            System.debug(A + ' is lexically before ' + B);
        else if (A.compareTo(B) > 0)
            System.debug(A + ' is lexically after ' + B);

        if (A.compareTo(B) >= 0)
            System.debug(A + ' is not lexically before ' + B);
        if (A.compareTo(B) <= 0)
            System.debug(A + ' is not lexically after ' + B);

        System.debug('The lexical relationship is: ' + A.compareTo(B));
    }
}


--Comparing two strings for exact equality
set s1 to "this"
set s2 to "that"
if s1 is s2 then
	-- strings are equal
end if

--Comparing two strings for inequality (i.e., the inverse of exact equality)
if s1 is not s2 then
	-- string are not equal
end if

-- Comparing two strings to see if one is lexically ordered before than the other
if s1 < s2 then
	-- s1 is lexically ordered before s2
end if

-- Comparing two strings to see if one is lexically ordered after than the other
if s1 > s2 then
	-- s1 is lexically ordered after s2
end if

-- How to achieve both case sensitive comparisons and case insensitive comparisons within the language
set s1 to "this"
set s2 to "This"

considering case
	if s1 is s2 then
		-- strings are equal with case considering
	end if
end considering

ignoring case -- default
	if s2 is s2 then
		-- string are equal without case considering
	end if
end ignoring

-- Demonstrate any other kinds of string comparisons that the language provides, particularly as it relates to your type system. For example, you might demonstrate the difference between generic/polymorphic comparison and coercive/allomorphic comparison if your language supports such a distinction.

-- When comparing the right object is coerced into the same type as the object left from the operator. This implicit coercion enables to compare integers with strings (containining integer values).

set s1 to "3"
set int1 to 2

if s1 < int1 then
	-- comparison is lexically
end if

if int1 < s1 then
	-- comparison is numeric
end if


/* ARM assembly Raspberry PI  */
/*  program comparString.s   */

/* Constantes    */
.equ STDOUT, 1     @ Linux output console
.equ EXIT,   1     @ Linux syscall
.equ WRITE,  4     @ Linux syscall
/* Initialized data */
.data
szMessStringEqu: .asciz "The strings are equals.\n"
szMessStringNotEqu: .asciz "The strings are not equals.\n"
szCarriageReturn:  .asciz "\n"

szString1:  .asciz "ABCDE"
szString2:  .asciz "ABCDE"
szString3:  .asciz "ABCFG"
szString4:   .asciz "ABC"
szString5:   .asciz "abcde"

/* UnInitialized data */
.bss

/*  code section */
.text
.global main
main:                /* entry of program  */
    push {fp,lr}    /* saves 2 registers */

    ldr r0,iAdrszString1
    ldr r1,iAdrszString2
    bl Comparaison

    ldr r0,iAdrszString1
    ldr r1,iAdrszString3
    bl Comparaison

    ldr r0,iAdrszString1
    ldr r1,iAdrszString4
    bl Comparaison

    @ case sensitive comparisons ABCDE et abcde
    ldr r0,iAdrszString1
    ldr r1,iAdrszString5
    bl Comparaison

    @ case insensitive comparisons  ABCDE et abcde
    ldr r0,iAdrszString1
    ldr r1,iAdrszString5
    bl comparStringsInsensitive
    cmp r0,#0
    bne 1f
    ldr r0,iAdrszMessStringEqu
    bl affichageMess
    b 2f
1:
    ldr r0,iAdrszMessStringNotEqu
    bl affichageMess

2:

100:   /* standard end of the program */
    mov r0, #0                  @ return code
    pop {fp,lr}                 @restaur 2 registers
    mov r7, #EXIT              @ request to exit program
    swi 0                       @ perform the system call
iAdrszString1: .int szString1
iAdrszString2: .int szString2
iAdrszString3: .int szString3
iAdrszString4: .int szString4
iAdrszString5: .int szString5
iAdrszMessStringEqu:  .int szMessStringEqu
iAdrszMessStringNotEqu:  .int szMessStringNotEqu
iAdrszCarriageReturn:  .int  szCarriageReturn
/*********************************************/
/* comparaison                               */
/*********************************************/
/* r0 contains address String 1           */
/* r1 contains address String 2         */
Comparaison:
    push {fp,lr}    			/* save  registres */
    bl comparStrings
    cmp r0,#0
    bne 1f
    ldr r0,iAdrszMessStringEqu
    bl affichageMess
    b 2f
1:
    ldr r0,iAdrszMessStringNotEqu
    bl affichageMess

2:
    pop {fp,lr}    				/* restaur des  2 registres */
    bx lr	        			/* return  */
/******************************************************************/
/*     display text with size calculation                         */
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
    push {fp,lr}    			/* save  registres */
    push {r0,r1,r2,r7}    		/* save others 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" */
    swi #0                      /* call systeme */
    pop {r0,r1,r2,r7}     		/* restaur others registers */
    pop {fp,lr}    				/* restaur des  2 registres */
    bx lr	        			/* return  */
/************************************/
/* Strings case sensitive comparisons  */
/************************************/
/* r0 et r1 contains the address of strings */
/* return 0 in r0 if equals */
/* return -1 if string r0 < string r1 */
/* return 1  if string r0 > string r1 */
comparStrings:
    push {r1-r4}  /* save des registres */
    mov r2,#0   /* counter */
1:
    ldrb r3,[r0,r2]   /* byte string 1 */
    ldrb r4,[r1,r2]   /* byte string 2 */
    cmp r3,r4
    movlt r0,#-1	 /* small */
    movgt r0,#1	 /* greather */
    bne 100f     /* not equals */
    cmp r3,#0   /* 0 end string */
    moveq r0,#0    /* equals */
    beq 100f     /*  end string */
    add r2,r2,#1 /* else add 1 in counter */
    b 1b         /* and loop */
100:
    pop {r1-r4}
    bx lr

/************************************/
/* Strings case insensitive comparisons    */
/************************************/
/* r0 et r1 contains the address of strings */
/* return 0 in r0 if equals */
/* return -1 if string r0 < string r1 */
/* return 1  if string r0 > string r1 */
comparStringsInsensitive:
    push {r1-r4}  /* save des registres */
    mov r2,#0   /* counter */

1:
    ldrb r3,[r0,r2]   /* byte string 1 */
    ldrb r4,[r1,r2]   /* byte string 2 */
    @ majuscules --> minuscules  byte 1
    cmp r3,#65
    blt 2f
    cmp r3,#90
    bgt 2f
    add r3,#32
2:   	@ majuscules --> minuscules  byte 2
    cmp r4,#65
    blt 3f
    cmp r4,#90
    bgt 3f
    add r4,#32
3:
    cmp r3,r4
    movlt r0,#-1	 /* small */
    movgt r0,#1	 /* greather */
    bne 100f     /* not equals */
    cmp r3,#0   /* 0 end string */
    moveq r0,#0    /* equal */
    beq 100f     /* end strings */
    add r2,r2,#1 /* else add 1 in counter */
    b 1b         /* and loop */
100:
    pop {r1-r4}
    bx lr   	/* end procedure */


fun compare(a, b):
    print("\n$a is of type ${typeof(a)} and $b is of type ${typeof(b)}")
    if a < b: print("$a is strictly less than $b")
    if a <= b: print("$a is less than or equal to $b")
    if a >  b: print("$a is strictly greater than $b")
    if a >= b: print("$a is greater than or equal to $b")
    if a == b: print("$a is equal to $b")
    if a != b: print("$a is not equal to $b")
    if a is b: print("$a has object identity with $b")
    if a is not b: print("$a has negated object identity with $b")

compare("YUP", "YUP")
compare('a', 'z')
compare("24", "123")
compare(24, 123)
compare(5.0, 5)


/* 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"


CHAR ARRAY S1,S2

Proc Main()
 S1="Hello, "
 S2="world!";
 Sassign(S1,S2,S1(0)+1)
 Print(S1)
Return


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;


Method "string comparisons_,_" is
[
    a : string,
    b : string
|
    Print: "a & b are equal? " ++ “a = b”;
    Print: "a & b are not equal? " ++ “a ≠ b”;
    // Inequalities compare by code point
    Print: "a is lexically before b? " ++ “a < b”;
    Print: "a is lexically after b? " ++ “a > b”;
    // Supports non-strict inequalities
    Print: "a is not lexically before b? " ++ “a ≥ b”;
    Print: "a is not lexically after b? " ++ “a ≤ b”;
    // Case-insensitive comparison requires a manual case conversion
    Print: "a & b are equal case-insensitively?" ++ “lowercase a = lowercase b”;
];


exact_equality(a,b){
	return (a==b)
}
exact_inequality(a,b){
	return !(a==b)
}
equality(a,b){
	return (a=b)
}
inequality(a,b){
	return !(a=b)
}
ordered_before(a,b){
	return ("" a < "" b)
}
ordered_after(a,b){
	return ("" a > "" b)
}


/* 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


BEGIN {
  a="BALL"
  b="BELL"

  if (a == b) { print "The strings are equal" }
  if (a != b) { print "The strings are not equal" }
  if (a  > b) { print "The first string is lexically after than the second" }
  if (a  < b) { print "The first string is lexically before than the second" }
  if (a >= b) { print "The first string is not lexically before than the second" }
  if (a <= b) { print "The first string is not lexically after than the second" }

  # to make a case insensitive comparison convert both strings to the same lettercase:
  a="BALL"
  b="ball"
  if (tolower(a) == tolower(b)) { print "The first and second string are the same disregarding letter case" }

}


10 LET "A$="BELL"
20 LET B$="BELT"
30 IF A$ = B$ THEN PRINT "THE STRINGS ARE EQUAL": REM TEST FOR EQUALITY
40 IF A$ <> B$ THEN PRINT "THE STRINGS ARE NOT EQUAL": REM TEST FOR INEQUALITY
50 IF A$ > B$ THEN PRINT A$;" IS LEXICALLY HIGHER THAN ";B$: REM TEST FOR LEXICALLY HIGHER
60 IF A$ < B$ THEN PRINT A$;" IS LEXICALLY LOWER THAN ";B$: REM TEST FOR LEXICALLY LOWER
70 IF A$ <= B$ THEN PRINT A$;" IS NOT LEXICALLY HIGHER THAN ";B$
80 IF A$ >= B$ THEN PRINT A$;" IS NOT LEXICALLY LOWER THAN ";B$
90 END


REM >strcomp
shav$ = "Shaw, George Bernard"
shakes$ = "Shakespeare, William"
:
REM test equality
IF shav$ = shakes$ THEN PRINT "The two strings are equal" ELSE PRINT "The two strings are not equal"
:
REM test inequality
IF shav$ <> shakes$ THEN PRINT "The two strings are unequal" ELSE PRINT "The two strings are not unequal"
:
REM test lexical ordering
IF shav$ > shakes$ THEN PRINT shav$; " is lexically higher than "; shakes$ ELSE PRINT shav$; " is not lexically higher than "; shakes$
IF shav$ < shakes$ THEN PRINT shav$; " is lexically lower than "; shakes$ ELSE PRINT shav$; " is not lexically lower than "; shakes$
REM the >= and <= operators can also be used, & behave as expected
:
REM string comparison is case-sensitive by default, and BBC BASIC
REM  does not provide built-in functions to convert to all upper
REM or all lower case; but it is easy enough to define one
:
IF FN_upper(shav$) = FN_upper(shakes$) THEN PRINT "The two strings are equal (disregarding case)" ELSE PRINT "The two strings are not equal (even disregarding case)"
END
:
DEF FN_upper(s$)
LOCAL i%, ns$
ns$ = ""
FOR i% = 1 TO LEN s$
  IF ASC(MID$(s$, i%, 1)) >= ASC "a" AND ASC(MID$(s$, i%, 1)) <= ASC "z" THEN ns$ += CHR$(ASC(MID$(s$, i%, 1)) - &20) ELSE ns$ += MID$(s$, i%, 1)
NEXT
= ns$


set {a, b} to {"Apple", "Script"}
set a to a & b
return a as string


      s←'hello'
      s,'world'
helloworld


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"


string s = "Hello";
s = s + " Wo";
s += "rld!";
write(s);


( {Comparing two strings for exact equality}
& ( ( @(abc:abc)
    & @(123:%123)
    {Previous pairs of strings are exactly equal}
    )
  & ( @(abc:Abc)
    | @(123:%246/2)
    | @(abc:ab)
    | @(123:%12)
    | {Previous pairs of strings are not exactly equal}
    )
  )
  {Comparing two strings for inequality (i.e., the inverse of exact equality)}
& ( ( @(abc:~<>abc)
    & @(abc:~<>Abc)
      {Previous pairs of strings are more or less equal}
    )
  & ( @(abc:~<>ab)
    | {Previous pairs of strings are not more or less equal}
    )
  )
  {Comparing two strings to see if one is lexically ordered before than the other}
& ( ( @(Abc:<abc)
    & @(Abc:<a)
    & @(123:<%246/2)
    & @(123:<%2)
    & @(12:<%123)
    & @(ab:<abc)
      {Previous pairs of strings are lexically ordered one before the other}
    )
  & ( @(abc:<abc)
    | @(abc:<Abc)
    | @(246/2:<%123)
    | @(abc:<ab)
    | @(123:<%12)
    | @(123:<%123)
    | {Previous pairs of strings are not lexically ordered one before the other}
    )
  )
  {Comparing two strings to see if one is lexically ordered after than the other}
& ( ( @(abc:>Abc)
    & @(a:>Abc)
    & @(246/2:>%123)
    & @(2:>%123)
    & @(123:>%12)
    & @(abc:>ab)
      {Previous pairs of strings are lexically ordered one after the other}
    )
  & ( @(abc:>abc)
    | @(Abc:>abc)
    | @(123:>%246/2)
    | @(ab:>abc)
    | @(12:>%123)
    | @(123:>%123)
    | {Previous pairs of strings are not lexically ordered one after the other}
    )
  )
  {How to achieve both case sensitive comparisons and case insensitive comparisons within
   the language}
& ( ( @(abc:~<>abc)
    & @(abc:~<>Abc)
    & @(БЪЛГАРСКИ:~<>български)
      {Previous pairs of strings are more or less equal}
    )
  & ( @(abc:~<>ab)
    | {Previous pairs of strings are not more or less equal}
    )
  )
  {How the language handles comparison of numeric strings if these are not treated lexically}
& ( ( @(246/2:123)
    & @(2:<123)
    & @(123:>12)
    & @(123:246/2)
    & @(12:<123)
      {Previous numeric string comparisons succeed}
    )
  & ( @(123:<246/2)
    | @(12:>123)
    | @(123:>123)
    | @(123:~123)
    | {Previous numeric string comparisons fail}
    )
  )
  {Demonstrate any other kinds of string comparisons that the language provides, particularly
as it relates to your type system. For example, you might demonstrate the difference between
generic/polymorphic comparison and coercive/allomorphic comparison if your language supports
such a distinction.}
& ( ( @(246/2:>12--3)
    & @(2:>123kg)
    & @(123:<12d)
    & @(123:~24/6/2)
    & @(12a:>123)
      {Previous coercive string comparisons succeed}
    )
  & ( @(2013-05-01:20130501)
    | @(246/2a:123a)
    | @(1239:<123-)
    | {Previous coercive string comparisons fail}
    )
  )
& done
);


blsq ) "abc""abc"==
1
blsq ) "abc""abc"!=
0
blsq ) "abc""Abc"cm
1
blsq ) "ABC""Abc"cm
-1


/* WRONG! */
if (strcmp(a,b)) action_on_equality();


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>

template <typename T>
void demo_compare(const T &a, const T &b, const std::string &semantically) {
    std::cout << a << " and " << b << " are " << ((a == b) ? "" : "not ")
              << "exactly " << semantically << " equal." << std::endl;

    std::cout << a << " and " << b << " are " << ((a != b) ? "" : "not ")
              << semantically << "inequal." << std::endl;

    std::cout << a << " is " << ((a < b) ? "" : "not ") << semantically
              << " ordered before " << b << '.' << std::endl;

    std::cout << a << " is " << ((a > b) ? "" : "not ") << semantically
              << " ordered after " << b << '.' << std::endl;
}

int main(int argc, char *argv[]) {
    // Case-sensitive comparisons.
    std::string a((argc > 1) ? argv[1] : "1.2.Foo");
    std::string b((argc > 2) ? argv[2] : "1.3.Bar");
    demo_compare<std::string>(a, b, "lexically");

    // Case-insensitive comparisons by folding both strings to a common case.
    std::transform(a.begin(), a.end(), a.begin(), ::tolower);
    std::transform(b.begin(), b.end(), b.begin(), ::tolower);
    demo_compare<std::string>(a, b, "lexically");

    // Numeric comparisons; here 'double' could be any type for which the
    // relevant >> operator is defined, eg int, long, etc.
    double numA, numB;
    std::istringstream(a) >> numA;
    std::istringstream(b) >> numB;
    demo_compare<double>(numA, numB, "numerically");
    return (a == b);
}


str : string := "99 bottles of ";
str ++= "beer";
Print: str;


# syntax: GAWK -f STRING_APPEND.AWK
BEGIN {
    s = "foo"
    s = s "bar"
    print(s)
    exit(0)
}


Lbl STRCAT
Copy(r₂,r₁+length(r₁),length(r₂)+1)
r₁
Return


S$ = "Hello"
S$ = S$ + " World!"
PRINT S$


str="Hello";
str$(!str " World!"):?str;
out$!str;


#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;
}


   IF s1 == s2
      ? "The strings are equal"
   ENDIF
   IF .NOT. (s1 == s2)
      ? "The strings are not equal"
   ENDIF
   IF s1 > s2
      ? "s2 is lexically ordered before than s1"
   ENDIF
   IF s1 < s2
      ? "s2 is lexically ordered after than s1"
   ENDIF


(= "abc" "def")   ; false
(= "abc" "abc")   ; true

(not= "abc" "def")   ; true
(not= "abc" "abc")   ; false


"hello" = "hello"   *> equality
"helloo" <> "hello" *> inequality
"aello" < "hello"   *> lexical ordering


class Program
{
    static void Main(string[] args)
    {
        string x = "foo";
        x += "bar";
        System.Console.WriteLine(x);
    }
}


#include <iostream>
#include <string>

int main( ) {
   std::string greeting( "Hello" ) ;
   greeting.append( " , world!" ) ;
   std::cout << greeting << std::endl ;
   return 0 ;
}


user=> (def s "app")
#'user/s
user=> s
"app"
user=> (def s (str s "end"))
#'user/s
user=> s
"append"


      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.


<cffunction name="CompareString">
    <cfargument name="String1" type="string">
    <cfargument name="String2" type="string">
    <cfset VARIABLES.Result = "" >
    <cfif ARGUMENTS.String1 LT ARGUMENTS.String2 >
	    <cfset VARIABLES.Result = VARIABLES.Result & "('" & ARGUMENTS.String1 & "' is less than '" & ARGUMENTS.String2 & "')" >
    </cfif>
    <cfif ARGUMENTS.String1 LTE ARGUMENTS.String2 >
	    <cfset VARIABLES.Result = VARIABLES.Result & "('" & ARGUMENTS.String1 & "' is less than or equal to '" & ARGUMENTS.String2 & "')" >
    </cfif>
    <cfif ARGUMENTS.String1 GT ARGUMENTS.String2 >
	    <cfset VARIABLES.Result = VARIABLES.Result & "('" & ARGUMENTS.String1 & "' is greater than '" & ARGUMENTS.String2 & "')" >
    </cfif>
    <cfif ARGUMENTS.String1 GTE ARGUMENTS.String2 >
	    <cfset VARIABLES.Result = VARIABLES.Result & "('" & ARGUMENTS.String1 & "' is greater than or equal to '" & ARGUMENTS.String2 & "')" >
    </cfif>
    <cfif ARGUMENTS.String1 EQ ARGUMENTS.String2 >
	    <cfset VARIABLES.Result = VARIABLES.Result & "('" & ARGUMENTS.String1 & "' is equal to '" & ARGUMENTS.String2 & "')" >
    </cfif>
    <cfif ARGUMENTS.String1 NEQ ARGUMENTS.String2 >
	    <cfset VARIABLES.Result = VARIABLES.Result & "('" & ARGUMENTS.String1 & "' is not equal to '" & ARGUMENTS.String2 & "')" >
    </cfif>
    <cfreturn VARIABLES.Result >
</cffunction>


>(string= "foo" "foo")
T
> (string= "foo" "FOO")
NIL
> (string/= "foo" "bar")
0
> (string/= "bar" "baz")
2
> (string/= "foo" "foo")
NIL
> (string> "foo" "Foo")
0
> (string< "foo" "Foo")
NIL
> (string>= "FOo" "Foo")
NIL
> (string<= "FOo" "Foo")
1


a = "Hello, "
b = "World!"
c = a + b

console.log c


(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*)


import std.stdio;

void main() {
    string s = "Hello";
    s ~= " world!";
    writeln(s);
}


;Concatenate "Hello world!"
STR='Hello'
STR(%TRIM(STR)+2:5)='world'
STR(%TRIM(STR)+1:1)='!'


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.


MODULE StringComparision;
IMPORT StdLog,Strings;

PROCEDURE Do*;
VAR
	str1,str2,aux1,aux2: ARRAY 128 OF CHAR;
BEGIN
	str1 := "abcde";str2 := "abcde";
	StdLog.String(str1+" equals " + str2  + ":> ");StdLog.Bool(str1 = str2);StdLog.Ln;
	str2 := "abcd";
	StdLog.String(str1+" equals " + str2  + ":> ");StdLog.Bool(str1 = str2);StdLog.Ln;
	StdLog.String(str1+" greater than " + str2  + ":> ");StdLog.Bool(str1 > str2);StdLog.Ln;
	StdLog.String(str1+" lower than " + str2  + ":> ");StdLog.Bool(str1 < str2);StdLog.Ln;

	str2 := "ABCDE";
	StdLog.String(str1+" equals " + str2  + ":> ");StdLog.Bool(str1 = str2);StdLog.Ln;
	StdLog.String(str1+" greater than " + str2  + ":> ");StdLog.Bool(str1 > str2);StdLog.Ln;
	StdLog.String(str1+" lower than " + str2  + ":> ");StdLog.Bool(str1 < str2);StdLog.Ln;

	Strings.ToLower(str1,aux1);Strings.ToLower(str2,aux2);
	StdLog.String(str1+" equals (case insensitive) " + str2  + ":> ");StdLog.Bool(aux1 = aux2);StdLog.Ln;

	str1 := "01234";str2 := "01234";
	StdLog.String(str1+" equals " + str2  + ":> ");StdLog.Bool(str1 = str2);StdLog.Ln;
	str2 := "0123";
	StdLog.String(str1+" equals " + str2  + ":> ");StdLog.Bool(str1 = str2);StdLog.Ln;
	StdLog.String(str1+" greater than " + str2  + ":> ");StdLog.Bool(str1 > str2);StdLog.Ln;
	StdLog.String(str1+" lower than " + str2  + ":> ");StdLog.Bool(str1 < str2);StdLog.Ln;
END Do;

END StringComparision.


import std.stdio, std.string, std.algorithm;

void main() {
    auto s = "abcd";

    /* Comparing two strings for exact equality */
    assert (s == "abcd"); // same object

    /* Comparing two strings for inequality */
    assert(s != "ABCD"); // different objects

    /* Comparing the lexical order of two strings;
    -1 means smaller, 0 means equal, 1 means larger */

    assert(s.icmp("Bcde") == -1); // case insensitive
    assert(s.cmp("Bcde") == 1); // case sensitive

    assert(s.icmp("Aabc") == 1); // case insensitive
    assert(s.cmp("Aabc") == 1); // case sensitive

    assert(s.icmp("ABCD") == 0); // case insensitive
    assert(s.cmp("ABCD") == 1); // case sensitive
}


;; 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"


import extensions;
import extensions'text;

public program()
{
    var s := StringWriter.load("Hello");
    s.append:" World";

    console.printLine:s.readChar()
}


iex(60)> s = "Hello"
"Hello"
iex(61)> s <> " World!"
"Hello World!"


(defvar str "foo")
(setq str (concat str "bar"))
str ;=> "foobar"


func compare(a, b) {
  if a == b {
    print("'\(a)' and '\(b)' are lexically equal.")
  }
  if a != b {
    print("'\(a)' and '\(b)' are not lexically equal.")
  }

  if a < b {
    print("'\(a)' is lexically before '\(b)'.")
  }
  if a > b {
    print("'\(a)' is lexically after '\(b)'.")
  }

  if a >= b {
    print("'\(a)' is not lexically before '\(b)'.")
  }
  if a <= b {
    print("'\(a)' is not lexically after '\(b)'.")
  }
}
compare("cat", "dog")


import extensions;

compareStrings = (val1,val2)
{
    if (val1 == val2) { console.printLine("The strings ",val1," and ",val2," are equal") };
    if (val1 != val2) { console.printLine("The strings ",val1," and ",val2," are not equal") };
    if (val1  > val2) { console.printLine("The string ",val1," is lexically after than ",val2) };
    if (val1  < val2) { console.printLine("The string ",val1," is lexically before than ",val2) };
    if (val1 >= val2) { console.printLine("The string ",val1," is not lexically before than ",val2) };
    if (val1 <= val2) { console.printLine("The string ",val1," is not lexically after than ",val2) }
};

public program()
{
    var s1 := "this";
    var s2 := "that";
    compareStrings(s1,s2);

    console.readChar()
}


s = "abcd"
s == "abcd"         #=> true
s == "abce"         #=> false
s != "abcd"         #=> false
s != "abce"         #=> true
s >  "abcd"         #=> false
s <  "abce"         #=> true
s >= "abce"         #=> false
s <= "abce"         #=> true


10> V = "abcd".
"abcd"
11> V =:= "abcd".
true
12> V =/= "abcd".
false
13> V < "b".
true
15> V > "aa".
true
16> string:to_lower(V) =:= string:to_lower("ABCD").
true


1> S = "Hello".
"Hello"
2> S ++ " world".
"Hello world"


sequence string = "String"

printf(1,"%s\n",{string})

string &= " is now longer\n"

printf(1,"%s",{string})


let mutable x = "foo"
x <- x + "bar"
printfn "%s" x


/* Added by Aykayayciti Earl Lamont Montgomery
April 10th, 2018 */

s1, s2 = "Hello", "Foo"
> s1 + " World"
printl(s2 + " bar")


open System

// self defined operators for case insensitive comparison
let (<~) a b  = String.Compare(a, b, StringComparison.OrdinalIgnoreCase) < 0
let (<=~) a b = String.Compare(a, b, StringComparison.OrdinalIgnoreCase) <= 0
let (>~) a b  = String.Compare(a, b, StringComparison.OrdinalIgnoreCase) > 0
let (>=~) a b = String.Compare(a, b, StringComparison.OrdinalIgnoreCase) >= 0
let (=~) a b  = String.Compare(a, b, StringComparison.OrdinalIgnoreCase) = 0
let (<>~) a b = String.Compare(a, b, StringComparison.OrdinalIgnoreCase) <> 0

let compare a b =   // standard operators:
    if a <  b then printfn "%s is strictly less than %s" a b
    if a <= b then printfn "%s is less than or equal to %s" a b
    if a >  b then printfn "%s is strictly greater than %s" a b
    if a >= b then printfn "%s is greater than or equal to %s" a b
    if a =  b then printfn "%s is equal to %s" a b
    if a <> b then printfn "%s is not equal to %s" a b
    // and our case insensitive self defined operators:
    if a <~  b then printfn "%s is strictly less than %s (case insensitive)" a b
    if a <=~ b then printfn "%s is less than or equal to %s (case insensitive)" a b
    if a >~  b then printfn "%s is strictly greater than %s (case insensitive)" a b
    if a >=~ b then printfn "%s is greater than or equal to %s (case insensitive)" a b
    if a =~  b then printfn "%s is equal to %s (case insensitive)" a b
    if a <>~ b then printfn "%s is not equal to %s (case insensitive)" a b

[<EntryPoint>]
let main argv =
    compare "YUP" "YUP"
    compare "BALL" "BELL"
    compare "24" "123"
    compare "BELL" "bELL"
    0


USING: ascii math.order sorting.human ;

IN: scratchpad "foo" "bar" = . ! compare for equality
f
IN: scratchpad "foo" "bar" = not . ! compare for inequality
t
IN: scratchpad "foo" "bar" before? . ! lexically ordered before?
f
IN: scratchpad "foo" "bar" after? . ! lexically ordered after?
t
IN: scratchpad "Foo" "foo" <=> . ! case-sensitive comparison
+lt+
IN: scratchpad "Foo" "foo" [ >lower ] [email protected] <=> . ! case-insensitive comparison
+eq+
IN: scratchpad "a1" "a03" <=> . ! comparing numeric strings
+gt+
IN: scratchpad "a1" "a03" human<=> . ! comparing numeric strings like a human
+lt+


\ 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"


program main

 character(len=:),allocatable :: str

 str = 'hello'
 str = str//' world'

 write(*,*) str

end program main


' FB 1.05.0 Win64

Var s = "String"
s += " append"
Print s
Sleep


Public Sub Main()
Dim sString As String = "Hello "

sString &= "World!"
Print sString

End


[indent=4]
/* String append, in Genie */
init
    str:string = "Hello"
    str += ", world"

    print str


var.string="This is "
var.string+="Sparta!"
debug=var.string


/* created by Aykayayciti Earl Lamont Montgomery
April 9th, 2018 */

e = "early"
l = "toast"
g = "cheese"
b = "cheese"
e2 = "early"
num1 = 123
num2 = 456

> e == e2 ? @ "$e equals $e2" : @ "$e does not equal $e2"
> e != e2 ? @ "$e does not equal $e2": @ "$e equals $e2"
// produces -1 for less than
> b.cmpi(l) == 1 ? @ "$b is grater than $l" : @ "$l is grater than $b"
// produces 1 for greater than
> l.cmpi(b) == 1 ? @ "$l is grater than $b" : @ "$b is grater than $l"
// produces 0 for equal (but could be greater than or equal)
> b.cmpi(g) == 1 or b.cmpi(g) == 0 ? @ "$b is grater than or equal to $g" : @ "$b is not >= $g"
// produces 0 for equal (but could be less than or equal)
>b.cmpi(g) == -1 or b.cmpi(g) == 0 ? @ "$b is less than or equal to $g" : @ "$b is not <= $g"

function NumCompare(num1, num2)
	if num1 < num2
		ans = " < "
	elif num1 > num2
		ans =  " > "
	else
		ans =  " = "
	end
	return ans
end

result = NumCompare(num1, num2)
> @ "$num1 $result $num2"


: str-eq  ( str len str len -- ? ) compare 0= ;
: str-neq ( str len str len -- ? ) compare 0<> ;
: str-lt  ( str len str len -- ? ) compare 0< ;
: str-gt  ( str len str len -- ? ) compare 0> ;
: str-le  ( str len str len -- ? ) compare 0<= ;
: str-ge  ( str len str len -- ? ) compare 0>= ;


      PRINT 42,N
   42 FORMAT (14HThe answer is ,I9)


// 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}")


class Append{
static void main(String[] args){
def c="Hello ";
def d="world";
def e=c+d;
println(e);
}
}


procedure main()
    s := "foo"
    s ||:= "bar"
    write(s)
end


   s=: 'new'
   s
new
   s=: s,' value'   NB. append is in-place
   s
new value


' FB 1.05.0

' Strings in FB natively support the relational operators which compare lexically on a case-sensitive basis.
' There are no special provisions for numerical strings.
' There are no other types of string comparison for the built-in types though 'user defined types'
' can specify their own comparisons by over-loading the relational operators.

Function StringCompare(s1 As Const String, s2 As Const String, ignoreCase As Boolean = false) As String
  Dim As String s, t ' need new string variables as the strings passed in can't be changed
  If ignoreCase Then
    s = LCase(s1)
    t = LCase(s2)
  Else
    s = s1
    t = s2
  End If
  If s < t Then Return " comes before "
  If s = t Then Return " is equal to "
  Return " comes after "
End Function

Dim As Integer result
Dim As String s1, s2, s3
s1 = "Dog" : s2 = "Dog"
Print s1; StringCompare(s1, s2); s2
s2 = "Cat"
Print s1; StringCompare(s1, s2); s2
s2 = "Rat"
Print s1; StringCompare(s1, s2); s2
s2 = "dog"
Print s1; StringCompare(s1, s2); s2
Print s1; StringCompare(s1, s2, True); s2; " if case is ignored"
s1  = "Dog" : s2 = "Pig"
s3 = StringCompare(s1, s2)
If s3 <> " is equal to " Then
  Print s1; " is not equal to "; s2
End If
Print
Print "Press any key to quit"
Sleep


package main

import (
    "fmt"
    "strings"
)

func main() {
    // Go language string comparison operators:
    c := "cat"
    d := "dog"
    if c == d {
        fmt.Println(c, "is bytewise identical to", d)
    }
    if c != d {
        fmt.Println(c, "is bytewise different from", d)
    }
    if c > d {
        fmt.Println(c, "is lexically bytewise greater than", d)
    }
    if c < d {
        fmt.Println(c, "is lexically bytewise less than", d)
    }
    if c >= d {
        fmt.Println(c, "is lexically bytewise greater than or equal to", d)
    }
    if c <= d {
        fmt.Println(c, "is lexically bytewise less than or equal to", d)
    }
    // Go is strongly typed and will not directly compare a value of string
    // type to a value of numeric type.

    // A case insensitive compare can be done with a function in the strings
    // package in the Go standard library:
    eqf := `when interpreted as UTF-8 and compared under Unicode
simple case folding rules.`
    if strings.EqualFold(c, d) {
        fmt.Println(c, "equal to", d, eqf)
    } else {
        fmt.Println(c, "not equal to", d, eqf)
    }

    // Seeing that the built in operators work bytewise and the library
    // case folding functions interpret UTF-8, you might then ask about
    // other equality and inequality tests that interpret UTF-8.
    // Functions for this are not in the Go standard library but are in
    // the Go "sub repository" at golang.org/x/text.  There is support
    // for Unicode normalization, collation tables, and locale sensitive
    // comparisons.
}


String sa = "Hello";
sa += ", World!";
System.out.println(sa);

StringBuilder ba = new StringBuilder();
ba.append("Hello");
ba.append(", World!");
System.out.println(ba.toString());


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!"));


"Hello" | . += ", world!"

["Hello"] | .[0] += ", world!" | .[0]

{ "greeting": "Hello"} | .greeting += ", world!" | .greeting


/* 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!=
*/


IF s1 == s2
   ? "The strings are equal"
ENDIF
IF !( s1 == s2 )
   ? "The strings are not equal"
ENDIF
IF s1 > s2
   ? "s2 is lexically ordered before than s1"
ENDIF
IF s1 < s2
   ? "s2 is lexically ordered after than s1"
ENDIF


> "abc" == "abc"
True
> "abc" /= "abc"
False
> "abc" <= "abcd"
True
> "abc" <= "abC"
False
> "HELLOWORLD" == "HelloWorld"
False
> :m +Data.Char
> map toLower "ABC"
"abc"
> map toLower "HELLOWORLD" == map toLower "HelloWorld"
True


procedure main(A)
    s1 := A[1] | "a"
    s2 := A[2] | "b"
    # These first four are case-sensitive
    s1 == s2        # Are they equal?
    s1 ~== s2       # Are they unequal?
    s1 << s2         # Does s1 come before s2?
    s1 >> s2         # Does s1 come after s2?
    map(s1) == map(s2)  # Caseless comparison
    "123" >> "12"    # Lexical comparison
    "123" > "12"     # Numeric comparison
    "123" >> 12      # Lexical comparison (12 coerced into "12")
    "123" > 12       # Numeric comparison ("123" coerced into 123)
end


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")
}


{def christian_name Albert}
-> christian_name
{def name de Jeumont-Schneidre}
-> name

{christian_name} {name}
-> Albert de Jeumont-Schneidre


var .s = "no more "
.s ~= "foo bars"
writeln .s


local(x = 'Hello')
#x->append(', World!')
#x


str = "Hello"
put " world!" after str
put str
-- "Hello world!"


function string:show ()
    print(self)
end

function string:append (s)
    self = self .. s
end

x = "Hi "
x:show()
x:append("there!")
x:show()


eq=: -:                         NB. equal
ne=: [email protected]:                      NB. not equal
gt=: {[email protected]/:@,&boxopen *. ne      NB. lexically greater than
lt=: [email protected]{[email protected]/:@,&boxopen *. ne   NB. lexically less than
ge=: {[email protected]/:@,&boxopen +. eq      NB. lexically greater than or equal to
le=: [email protected]{[email protected]/:@,&boxopen         NB. lexically less than or equal to


public class Compare
{
    public static void main (String[] args)
    {
        compare("Hello", "Hello");
        compare("5", "5.0");
        compare("java", "Java");
        compare("ĴÃVÁ", "ĴÃVÁ");
        compare("ĴÃVÁ", "ĵãvá");
    }
    public static void compare (String A, String B)
    {
        if (A.equals(B))
            System.out.printf("'%s' and '%s' are lexically equal.", A, B);
        else
            System.out.printf("'%s' and '%s' are not lexically equal.", A, B);
        System.out.println();

        if (A.equalsIgnoreCase(B))
            System.out.printf("'%s' and '%s' are case-insensitive lexically equal.", A, B);
        else
            System.out.printf("'%s' and '%s' are not case-insensitive lexically equal.", A, B);
        System.out.println();

        if (A.compareTo(B) < 0)
            System.out.printf("'%s' is lexically before '%s'.\n", A, B);
        else if (A.compareTo(B) > 0)
            System.out.printf("'%s' is lexically after '%s'.\n", A, B);

        if (A.compareTo(B) >= 0)
            System.out.printf("'%s' is not lexically before '%s'.\n", A, B);
        if (A.compareTo(B) <= 0)
            System.out.printf("'%s' is not lexically after '%s'.\n", A, B);

        System.out.printf("The lexical relationship is: %d\n", A.compareTo(B));
        System.out.printf("The case-insensitive lexical relationship is: %d\n\n", A.compareToIgnoreCase(B));
    }
}


a$="ok"
a$+="(one)"
Print a$

Document b$
b$="ok"
b$="(one)"
Print b$


a := "Hello";
b := cat(a, " World");
c := `||`(a, " World");


(* mutable strings are not supported *)
s1 = "testing";
s1 = s1 <> " 123";
s1


(quote cons "" join) :str-append

"foo" "bar" str-append puts!


s1 = "this is"
s1 += " a test"

println s1


/**
 <doc>
String append in Neko
</doc>
**/

var str = "Hello"
str += ", world"
$print(str, "\n")


/*
== equal value
=== equal value and equal type
!= not equal value
!== not equal value or not equal type
< lexically ordered before
> lexically ordered after
*/

console.log(
"abcd" == "abcd", // true
"abcd" === "abcd", // true
123 == "123", // true
123 === "123", // false
"ABCD" == "abcd", // false
"ABCD" != "abcd", // true
123 != "123", // false
123 !== "123", // true
"abcd" < "dcba", // true
"abcd" > "dcba", // false
"ABCD".toLowerCase() == "abcd".toLowerCase(), // true (case insensitive)
)


# Comparing two strings for exact equality:
"this" == "this"     # true
"this" == "This"     # false

# != is the inverse of ==

# Comparing two strings to see if one is lexically ordered before the other:
"alpha" < "beta"     # true
"beta" < "alpha"     # false

# > is the inverse of <


function compare(a, b)
    println("\n$a is of type $(typeof(a)) and $b is of type $(typeof(b))")
    if a <  b println("$a is strictly less than $b") end
    if a <= b println("$a is less than or equal to $b") end
    if a >  b println("$a is strictly greater than $b") end
    if a >= b println("$a is greater than or equal to $b") end
    if a == b println("$a is equal to $b") end
    if a != b println("$a is not equal to $b") end
    if a === b println("$a has object identity with $b") end
    if a !== b println("$a has negated object identity with $b") end
end

compare("YUP", "YUP")
compare('a', 'z')
compare("24", "123")
compare(24, 123)
compare(5.0, 5)


(setq str "foo")

(push "bar" str -1)
; or as an alternative introduced in v.10.1
(extend str "bar")

(println str)


var str = "123456"
str.add("78") # Using procedure "add".
str &= "9!"   # Using operator "&=".
echo str


10 S$ = "HELLO"
20 S$ = S$ + " WORLD!"
30 PRINT S$


class Append {
  function : Main(args : String[]) ~ Nil {
    x := "foo";
    x->Append("bar");
    x->PrintLine();
  }
}


let () =
  let s = Buffer.create 17 in
  Buffer.add_string s "Bonjour";
  Buffer.add_string s " tout le monde!";
  print_endline (Buffer.contents s)


// version 1.0.6

fun main(args: Array<String>) {
    val k1 = "kotlin"
    val k2 = "Kotlin"
    println("Case sensitive comparisons:\n")
    println("kotlin and Kotlin are equal     = ${k1 == k2}")
    println("kotlin and Kotlin are not equal = ${k1 != k2}")
    println("kotlin comes before Kotlin      = ${k1 < k2}")
    println("kotlin comes after Kotlin       = ${k1 > k2}")
    println("\nCase insensitive comparisons:\n")
    println("kotlin and Kotlin are equal     = ${k1 == k2.toLowerCase()}")
    println("kotlin and Kotlin are not equal = ${k1 != k2.toLowerCase()}")
    println("kotlin comes before Kotlin      = ${k1 < k2.toLowerCase()}")
    println("kotlin comes after Kotlin       = ${k1 > k2.toLowerCase()}")
}


// Comparing two strings for exact equality
"'this' == 'this': " + ('this' == 'this') // true
"'this' == 'This': " + ('this' == 'This') // true, as it's case insensitive

// Comparing two strings for inequality (i.e., the inverse of exact equality)
"'this' != 'this': " + ('this' != 'this')// false
"'this' != 'that': " + ('this' != 'that') // true

// Comparing two strings to see if one is lexically ordered before than the other
"'alpha' < 'beta': " + ('alpha' < 'beta') // true
"'beta' < 'alpha': " + ('beta' < 'alpha') // false

// Comparing two strings to see if one is lexically ordered after than the other
"'alpha' > 'beta': " + ('alpha' > 'beta') // false
"'beta' > 'alpha': " + ('beta' > 'alpha') // true

// How to achieve both case sensitive comparisons and case insensitive comparisons within the language
"case sensitive - 'this'->equals('This',-case=true): " + ('this'->equals('This',-case=true)) // false
"case insensitive - 'this'->equals('This',-case=true): " + ('this'->equals('This')) // true

// How the language handles comparison of numeric strings if these are not treated lexically
"'01234' == '01234': "+ ('01234' == '01234') // true
"'01234' == '0123': " + ('01234' == '0123') // false
"'01234' > '0123': " + ('01234' > '0123') // true
"'01234' < '0123': " + ('01234' < '0123') //false

// Additional string comparisons
"'The quick brown fox jumps over the rhino' >> 'fox' (contains): " +
    ('The quick brown fox jumps over the rhino' >> 'fox') // true
"'The quick brown fox jumps over the rhino' >> 'cat' (contains): " +
    ('The quick brown fox jumps over the rhino' >> 'cat') // false
"'The quick brown fox jumps over the rhino'->beginswith('rhino'): " +
    ('The quick brown fox jumps over the rhino'->beginswith('rhino')) // false
"'The quick brown fox jumps over the rhino'->endswith('rhino'): " +
    ('The quick brown fox jumps over the rhino'->endswith('rhino')) // true


put "abc"="ABC"
-- 1

put "abc"<>"def"
-- 1

put "abc"<"def"
-- 1

put "abc">"def"
-- 0


function compare(a, b)
    print(("%s is of type %s and %s is of type %s"):format(
        a, type(a),
        b, type(b)
    ))
    if a <  b then print(('%s is strictly less than %s'):format(a, b)) end
    if a <= b then print(('%s is less than or equal to %s'):format(a, b)) end
    if a >  b then print(('%s is strictly greater than %s'):format(a, b)) end
    if a >= b then print(('%s is greater than or equal to %s'):format(a, b)) end
    if a == b then print(('%s is equal to %s'):format(a, b)) end
    if a ~= b then print(('%s is not equal to %s'):format(a, b)) end
    print ""
end

compare('YUP', 'YUP')
compare('BALL', 'BELL')
compare('24', '123')
compare(24, 123)
compare(5.0, 5)


StringBuffer new "Hello, " << "World!" << println


program StringAppend;
{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { you can add units after this };

var
    s: String = 'Hello';
begin
  s += ' World !';
  WriteLn(S);
  ReadLn;
end.


my $str = 'Foo';
$str .= 'bar';
print $str;


string s = "this string"        ?s
s &= " is now longer"           ?s


main =>
  S = "a string",
  S := S + " that is longer",
  println(S).


(setq Str1 "12345678")
(setq Str1 (pack Str1 "9!"))
(println Str1)


compare[x_, y_] := Module[{},
  If[x == y,
   Print["Comparing for equality (case sensitive): " <> x <> " and " <> y <> " ARE equal"],
   Print["Comparing for equality (case sensitive): " <> x <> " and " <> y <> " are NOT equal" ]] ;
  If[x != y,
   Print["Comparing for inequality (case sensitive): " <> x <> " and " <> y <> " are NOT equal"],
   Print["Comparing for inequality (case sensitive): " <> x <> " and " <> y <> " ARE equal" ]] ;
  Switch[Order[x, y],
    1, Print["Comparing for order (case sensitive): " <> x <> " comes before " <> y],
   -1, Print["Comparing for order (case sensitive): " <> x <> " comes after " <> y],
    0, Print["Comparing for order (case sensitive): " <> x <> " comes in the same spot as " <> y]];
  If[ToLowerCase[x] == ToLowerCase[y],
   Print["Comparing for equality (case insensitive): " <> x <> " and " <> y <> " ARE equal"],
   Print["Comparing for equality (case insensitive): " <> x <> " and " <> y <> " are NOT equal" ]] ;
  Print[];
  ]
compare["Hello", "Hello"]
compare["3.1", "3.14159"]
compare["mathematica", "Mathematica"]


  a="BALL";
  b="BELL";

  if a==b, disp('The strings are equal'); end;
  if strcmp(a,b), disp('The strings are equal'); end;
  if a~=b, disp('The strings are not equal'); end;
  if ~strcmp(a,b), disp('The strings are not equal'); end;
  if a > b, disp('The first string is lexically after than the second'); end;
  if a < b, disp('The first string is lexically before than the second'); end;
  if a >= b, disp('The first string is not lexically before than the second'); end;
  if a <= b, disp('The first string is not lexically after than the second'); end;

  % to make a case insensitive comparison convert both strings to the same lettercase:
  a="BALL";
  b="ball";
  if strcmpi(a,b), disp('The first and second string are the same disregarding letter case'); end;
  if lower(a)==lower(b), disp('The first and second string are the same disregarding letter case'); end;