Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -1,3 +1,4 @@
|
|||
{{basic data operation}}Create a string variable equal to any text value. Create another string variable whose value is the original variable concatenated with another string literal.
|
||||
{{basic data operation}}
|
||||
Create a string variable equal to any text value. Create another string variable whose value is the original variable concatenated with another string literal.
|
||||
|
||||
To illustrate the operation, show the content of the variables.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- String manipulation
|
||||
- String manipulation
|
||||
note: Basic language learning
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
s$ = "hello"
|
||||
print s$;" literal" 'or s$ + " literal"
|
||||
s2$ = s$ + " literal"
|
||||
print s2$
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
stringvar1$ = "Hello,"
|
||||
stringvar2$ = stringvar1$ + " world!"
|
||||
PRINT "Variable 1 is """ stringvar1$ """"
|
||||
PRINT "Variable 2 is """ stringvar2$ """"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
10 LET s$="Hello"
|
||||
20 LET s$=s$+" World!"
|
||||
30 PRINT s$
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
set string=Hello
|
||||
echo %string% World
|
||||
set string2=%string% World
|
||||
echo %string2%
|
||||
|
|
|
|||
15
Task/String-concatenation/COBOL/string-concatenation-1.cobol
Normal file
15
Task/String-concatenation/COBOL/string-concatenation-1.cobol
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. Concat.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 Str PIC X(7) VALUE "Hello, ".
|
||||
01 Str2 PIC X(15).
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
DISPLAY "Str : " Str
|
||||
STRING Str " World!" DELIMITED BY SIZE INTO Str2
|
||||
DISPLAY "Str2 : " Str2
|
||||
|
||||
GOBACK
|
||||
.
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
...
|
||||
PROCEDURE DIVISION.
|
||||
DISPLAY "Str : " Str
|
||||
MOVE FUNCTION CONCATENATE(Str, " World!") TO Str2
|
||||
DISPLAY "Str2 : " Str2
|
||||
|
||||
GOBACK
|
||||
.
|
||||
11
Task/String-concatenation/COBOL/string-concatenation-3.cobol
Normal file
11
Task/String-concatenation/COBOL/string-concatenation-3.cobol
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
* *> Using a '&'.
|
||||
01 Long-Str-Val PIC X(200) VALUE "Lorem ipsum dolor sit "
|
||||
& "amet, consectetuer adipiscing elit, sed diam nonummy "
|
||||
& "nibh euismod tincidunt ut laoreet dolore magna aliquam "
|
||||
& "erat volutpat.".
|
||||
|
||||
* *> Using a '-' in column 7. Note the first two literals have no
|
||||
* *> closing quotes.
|
||||
01 Another-Long-Str PIC X(200) VALUE " Ut wisi enim ad minim
|
||||
- "veniam, quis nostrud exerci tation ullamcorper suscipit
|
||||
- "lobortis nisl ut aliquip ex ea commodo consequat".
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
MODULE StringConcatenation;
|
||||
IMPORT StdLog;
|
||||
|
||||
PROCEDURE Do*;
|
||||
VAR
|
||||
str1,str2: ARRAY 128 OF CHAR;
|
||||
BEGIN
|
||||
str1 := "Hello";
|
||||
str2 := str1 + " world";
|
||||
StdLog.String(":> " + str2);StdLog.Ln
|
||||
END Do;
|
||||
|
||||
END StringConcatenation.
|
||||
|
|
@ -0,0 +1 @@
|
|||
=CONCATENATE(A1;" ";B1)
|
||||
|
|
@ -0,0 +1 @@
|
|||
Hello World Hello World
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
var str, str1 = "String"
|
||||
echo(str & " literal.")
|
||||
str1 = str1 & " literal."
|
||||
echo(str1)
|
||||
|
||||
# -> String literal.
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
var str1 = "String"
|
||||
echo(join([str1, " literal.", "HelloWorld!"], "~~"))
|
||||
|
||||
# -> String~~ literal.~~HelloWorld!
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
var str1 = "String"
|
||||
echo "$# $# $#" % [str1, "literal.", "HelloWorld!"]
|
||||
|
||||
# -> String literal. HelloWorld!
|
||||
20
Task/String-concatenation/Rust/string-concatenation.rust
Normal file
20
Task/String-concatenation/Rust/string-concatenation.rust
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* String concatenation in Rust.
|
||||
* Copyright by Shlomi Fish, 2013.
|
||||
* Released under the MIT/X11 License
|
||||
* ( http://en.wikipedia.org/wiki/MIT_License ).
|
||||
* */
|
||||
|
||||
// rust 0.8
|
||||
|
||||
fn main() {
|
||||
let s = ~"hello";
|
||||
println!("s={}", s + " world");
|
||||
|
||||
let s1 = s + " world";
|
||||
println!("s1={}", s1);
|
||||
|
||||
let mut mutable_s = ~"hello";
|
||||
mutable_s.push_str(" world");
|
||||
println!("mutable_s={}", mutable_s);
|
||||
}
|
||||
|
|
@ -3,4 +3,7 @@ data _null_;
|
|||
b="World!";
|
||||
c=a !! " " !! b;
|
||||
put c;
|
||||
*Alternative using the catx function;
|
||||
c=catx (" ", a, b);
|
||||
put c;
|
||||
run;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue