Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
30
Task/String-case/COBOL/string-case-1.cobol
Normal file
30
Task/String-case/COBOL/string-case-1.cobol
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. string-case-85.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 example PIC X(9) VALUE "alphaBETA".
|
||||
|
||||
01 result PIC X(9).
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
DISPLAY "Example: " example
|
||||
|
||||
*> Using the intrinsic functions.
|
||||
DISPLAY "Lower-case: " FUNCTION LOWER-CASE(example)
|
||||
|
||||
DISPLAY "Upper-case: " FUNCTION UPPER-CASE(example)
|
||||
|
||||
*> Using INSPECT
|
||||
MOVE example TO result
|
||||
INSPECT result CONVERTING "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
TO "abcdefghijklmnopqrstuvwxyz"
|
||||
DISPLAY "Lower-case: " result
|
||||
|
||||
MOVE example TO result
|
||||
INSPECT result CONVERTING "abcdefghijklmnopqrstuvwxyz"
|
||||
TO "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
DISPLAY "Upper-case: " result
|
||||
|
||||
GOBACK
|
||||
.
|
||||
32
Task/String-case/COBOL/string-case-2.cobol
Normal file
32
Task/String-case/COBOL/string-case-2.cobol
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. string-case-extensions.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
78 example VALUE "alphaBETA".
|
||||
|
||||
01 result PIC X(9).
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
DISPLAY "Example: " example
|
||||
|
||||
*> ACUCOBOL-GT
|
||||
MOVE example TO result
|
||||
CALL "C$TOLOWER" USING result, BY VALUE 9
|
||||
DISPLAY "Lower-case: " result
|
||||
|
||||
MOVE example TO result
|
||||
CALL "C$TOUPPER" USING result, BY VALUE 9
|
||||
DISPLAY "Upper-case: " result
|
||||
|
||||
*> Visual COBOL
|
||||
MOVE example TO result
|
||||
CALL "CBL_TOLOWER" USING result, BY VALUE 9
|
||||
DISPLAY "Lower-case: " result
|
||||
|
||||
MOVE example TO result
|
||||
CALL "CBL_TOUPPER" USING result BY VALUE 9
|
||||
DISPLAY "Upper-case: " result
|
||||
|
||||
GOBACK
|
||||
.
|
||||
15
Task/String-case/Component-Pascal/string-case.component
Normal file
15
Task/String-case/Component-Pascal/string-case.component
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
MODULE AlphaBeta;
|
||||
IMPORT StdLog,Strings;
|
||||
|
||||
PROCEDURE Do*;
|
||||
VAR
|
||||
str,res: ARRAY 128 OF CHAR;
|
||||
BEGIN
|
||||
str := "alphaBETA";
|
||||
Strings.ToUpper(str,res);
|
||||
StdLog.String("Uppercase:> ");StdLog.String(res);StdLog.Ln;
|
||||
Strings.ToLower(str,res);
|
||||
StdLog.String("Lowercase:> ");StdLog.String(res);StdLog.Ln
|
||||
END Do;
|
||||
|
||||
END AlphaBeta.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import std.stdio, std.string;
|
||||
|
||||
void main() {
|
||||
auto s = "alphaBETA";
|
||||
writeln(s.toUpper());
|
||||
writeln(s.toLower());
|
||||
import std.stdio, std.string;
|
||||
|
||||
immutable s = "alphaBETA";
|
||||
s.toUpper.writeln;
|
||||
s.toLower.writeln;
|
||||
}
|
||||
|
|
|
|||
1
Task/String-case/Excel/string-case-1.excel
Normal file
1
Task/String-case/Excel/string-case-1.excel
Normal file
|
|
@ -0,0 +1 @@
|
|||
=LOWER(A1)
|
||||
1
Task/String-case/Excel/string-case-2.excel
Normal file
1
Task/String-case/Excel/string-case-2.excel
Normal file
|
|
@ -0,0 +1 @@
|
|||
=UPPER(A1)
|
||||
1
Task/String-case/Excel/string-case-3.excel
Normal file
1
Task/String-case/Excel/string-case-3.excel
Normal file
|
|
@ -0,0 +1 @@
|
|||
alphaBETA alphabeta ALPHABETA
|
||||
2
Task/String-case/Maxima/string-case.maxima
Normal file
2
Task/String-case/Maxima/string-case.maxima
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
supcase('alphaBETA');
|
||||
sdowncase('alphaBETA');
|
||||
7
Task/String-case/Nimrod/string-case.nimrod
Normal file
7
Task/String-case/Nimrod/string-case.nimrod
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import strutils
|
||||
|
||||
var s: string = "alphaBETA_123"
|
||||
echo s," as upper case: ", toUpper(s)
|
||||
echo s," as lower case: ", toLower(s)
|
||||
echo s," as Capitalized: ", capitalize(s)
|
||||
echo s," as normal case: ", normalize(s) # remove underscores, toLower
|
||||
65
Task/String-case/Pascal/string-case.pascal
Normal file
65
Task/String-case/Pascal/string-case.pascal
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
// Uppercase and Lowercase functions for a minimal standard Pascal
|
||||
// where no library routines for these operations exist
|
||||
PROGRAM upperlower;
|
||||
|
||||
// convert a character to uppercase
|
||||
FUNCTION uch(ch: CHAR): CHAR;
|
||||
BEGIN
|
||||
uch := ch;
|
||||
IF ch IN ['a'..'z'] THEN
|
||||
uch := chr(ord(ch) AND $5F);
|
||||
END;
|
||||
|
||||
// convert a character to lowercase
|
||||
FUNCTION lch(ch: CHAR): CHAR;
|
||||
BEGIN
|
||||
lch := ch;
|
||||
IF ch IN ['A'..'Z'] THEN
|
||||
lch := chr(ord(ch) OR $20);
|
||||
END;
|
||||
|
||||
// toggle uper/lower case character
|
||||
FUNCTION ulch(ch: CHAR): CHAR;
|
||||
BEGIN
|
||||
ulch := ch;
|
||||
IF ch IN ['a'..'z'] THEN ulch := uch(ch);
|
||||
IF ch IN ['A'..'Z'] THEN ulch := lch(ch);
|
||||
END;
|
||||
|
||||
// convert a string to uppercase
|
||||
FUNCTION ucase(str: STRING): STRING;
|
||||
var i: Integer;
|
||||
BEGIN
|
||||
ucase := '';
|
||||
FOR i := 1 TO Length(str) DO
|
||||
ucase := ucase + uch(str[i]);
|
||||
END;
|
||||
|
||||
// convert a string to lowercase
|
||||
FUNCTION lcase(str: STRING): STRING;
|
||||
var i: Integer;
|
||||
BEGIN
|
||||
lcase := '';
|
||||
FOR i := 1 TO Length(str) DO
|
||||
lcase := lcase + lch(str[i]);
|
||||
END;
|
||||
|
||||
// reverse cases in a given string
|
||||
FUNCTION ulcase(str: STRING): STRING;
|
||||
var i: Integer;
|
||||
BEGIN
|
||||
ulcase := '';
|
||||
FOR i := 1 TO Length(str) DO
|
||||
ulcase := ulcase + ulch(str[i]);
|
||||
END;
|
||||
|
||||
VAR
|
||||
ab : STRING = 'alphaBETA';
|
||||
|
||||
BEGIN
|
||||
// demonstration
|
||||
Writeln('Original string : ',ab);
|
||||
Writeln('Reversed case : ',ulcase(ab));
|
||||
Writeln('Upper case : ',ucase(ab));
|
||||
Writeln('Lower case : ',lcase(ab));
|
||||
END.
|
||||
Loading…
Add table
Add a link
Reference in a new issue