all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1 @@
Take the string "alphaBETA", and demonstrate how to convert it to UPPER-CASE and lower-case. Use the default encoding of a string literal or plain ASCII if there is no string literal in your language. Show any additional case conversion functions (e.g. swapping case, capitalizing the first letter, etc.) that may be included in the library of your language.

View file

@ -0,0 +1,2 @@
---
note: String manipulation

View file

@ -0,0 +1,3 @@
$string:="alphaBETA"
$uppercase:=Uppercase($string)
$lowercase:=Lowercase($string)

View file

@ -0,0 +1,101 @@
.lf case6502.lst
.cr 6502
.tf case6502.obj,ap1
;------------------------------------------------------
; String Case for the 6502 by barrym95838 2013.04.07
; Thanks to sbprojects.com for a very nice assembler!
; The target for this assembly is an Apple II with
; mixed-case output capabilities. Apple IIs like to
; work in '+128' ascii, so this version leaves bit 7
; alone, and can be used with either flavor.
; 6502s work best with data structures < 256 bytes;
; several instructions would have to be added to
; properly deal with longer strings.
; Tested and verified on AppleWin 1.20.0.0
;------------------------------------------------------
; Constant Section
;
StrPtr = $6 0-page temp pointer (2 bytes)
Low = $8 0-page temp low bound
High = $9 0-page temp high bound
CharOut = $fded Specific to the Apple II
BigA = "A" 'A' for normal ascii
BigZ = "Z" 'Z' " " "
LittleA = "a" 'a' " " "
LittleZ = "z" 'z' " " "
;======================================================
.or $0f00
;------------------------------------------------------
; The main program
;
main ldx #sTest Point to the test string
lda /sTest
jsr puts print it to stdout
jsr toUpper convert to UPPER-case
jsr puts print it
jsr toLower convert to lower-case
jmp puts print it and return to caller
;------------------------------------------------------
toUpper pha save A
lda #LittleA
sta Low set up the flip range
lda #LittleZ
bne toLow2 return via toLower's tail
;------------------------------------------------------
toLower pha save A
lda #BigA
sta Low set up the flip range
lda #BigZ
toLow2 sta High
pla restore A
; return via fall-thru to flip
;------------------------------------------------------
; Given a NUL-terminated string at A:X, flip the case
; of any chars in the range [Low..High], inclusive;
; only works on the first 256 bytes of a long string
; Uses: StrPtr, Low, High
; Preserves: A, X
; Trashes: Y
;
flip stx StrPtr init string pointer
sta StrPtr+1
ldy #0
pha save A
flip2 lda (StrPtr),y get string char
beq flip5 done if NUL
cmp Low
bcc flip4 if Low <= char <= High
cmp High
beq flip3
bcs flip4
flip3 eor #$20 then flip the case
sta (StrPtr),y
flip4 iny point to next char
bne flip2 loop up to 255 times
flip5 pla restore A
rts return
;------------------------------------------------------
; Output NUL-terminated string @ A:X; strings longer
; than 256 bytes are truncated there
; Uses: StrPtr
; Preserves: A, X
; Trashes: Y
;
puts stx StrPtr init string pointer
sta StrPtr+1
ldy #0
pha save A
puts2 lda (StrPtr),y get string char
beq puts3 done if NUL
jsr CharOut output the char
iny point to next char
bne puts2 loop up to 255 times
puts3 pla restore A
rts return
;------------------------------------------------------
; Test String (in '+128' ascii, Apple II style)
;
sTest .as -"Alpha, BETA, gamma, {[(<123@_>)]}."
.az -#13
;------------------------------------------------------
.en

View file

@ -0,0 +1,31 @@
#!/usr/local/bin/a68g --script #
# Demonstrate toupper and tolower for standard ALGOL 68
strings. This does not work for multibyte character sets. #
INT l2u = ABS "A" - ABS "a";
PROC to upper = (CHAR c)CHAR:
(ABS "a" > ABS c | c |: ABS c > ABS "z" | c | REPR ( ABS c + l2u ));
PROC to lower = (CHAR c)CHAR:
(ABS "A" > ABS c | c |: ABS c > ABS "Z" | c | REPR ( ABS c - l2u ));
# Operators can be defined in ALGOL 68 #
OP (CHAR)CHAR TOLOWER = to lower, TOUPPER = to upper;
# upper-cases s in place #
PROC string to upper = (REF STRING s)VOID:
FOR i FROM LWB s TO UPB s DO s[i] := to upper(s[i]) OD;
# lower-cases s in place #
PROC string to lower = (REF STRING s)VOID:
FOR i FROM LWB s TO UPB s DO s[i] := to lower(s[i]) OD;
main: (
STRING t := "alphaBETA";
string to upper(t);
printf(($"uppercase: "gl$, t));
string to lower(t);
printf(($"lowercase: "gl$, t))
)

View file

@ -0,0 +1,9 @@
AlphLower'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'
AlphUpper'ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ*'
AlphUpper[AlphLower'I'm using APL!']
I*M USING APL*
AlphLower'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ*'
AlphUpper'ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ'
AlphLower[AlphUpper'I'm using APL!']
i*m using apl*

View file

@ -0,0 +1,4 @@
BEGIN {
a = "alphaBETA";
print toupper(a), tolower(a)
}

View file

@ -0,0 +1,4 @@
BEGIN {
a = "alphaBETA";
print toupper(substr(a, 1, 1)) tolower(substr(a, 2))
}

View file

@ -0,0 +1,3 @@
var string:String = 'alphaBETA';
var upper:String = string.toUpperCase();
var lower:String = string.toLowerCase();

View file

@ -0,0 +1,9 @@
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Text_Io; use Ada.Text_Io;
procedure Upper_Case_String is
S : String := "alphaBETA";
begin
Put_Line(To_Upper(S));
Put_Line(To_Lower(S));
end Upper_Case_String;

View file

@ -0,0 +1,2 @@
main():
uppercase('alphaBETA') + '\n' + lowercase('alphaBETA') + '\n' -> io

View file

@ -0,0 +1,5 @@
a := "alphaBETA"
StringLower, b, a ; alphabeta
StringUpper, c, a ; ALPHABETA
StringUpper, d, a, T ; Alphabeta (T = title case) eg "alpha beta gamma" would become "Alpha Beta Gamma"

View file

@ -0,0 +1,3 @@
$sString = "alphaBETA"
$sUppercase = StringUpper($sString) ;"ALPHABETA"
$sLowercase = StringLower($sString) ;"alphabeta"

View file

@ -0,0 +1,3 @@
s$ = "alphaBETA"
PRINT UCASE$(s$)
PRINT LCASE$(s$)

View file

@ -0,0 +1,7 @@
INSTALL @lib$+"STRINGLIB"
original$ = "alphaBETA"
PRINT "Original: " original$
PRINT "Lower case: " FN_lower(original$)
PRINT "Upper case: " FN_upper(original$)
PRINT "Title case: " FN_title(original$)

View file

@ -0,0 +1,4 @@
"ATEBahpla" > : #v_ 25* , @ >48*-v
> :: "`"` \"{"\` * | > , v
> ^
^ <

View file

@ -0,0 +1,2 @@
"alphaBETA":?s
& out$str$(upp$!s \n low$!s)

View file

@ -0,0 +1,3 @@
blsq ) "alphaBETA"^^zz\/ZZ
"ALPHABETA"
"alphabeta"

View file

@ -0,0 +1,21 @@
#include <algorithm>
#include <string>
#include <cctype>
/// \brief in-place convert string to upper case
/// \return ref to transformed string
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
/// \brief in-place convert string to lower case
/// \return ref to transformed string
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}

View file

@ -0,0 +1,12 @@
#include <iostream>
#include <string>
using namespace std;
int main() {
string foo("_upperCas3Me!!");
str_toupper(foo);
cout << foo << endl;
str_tolower(foo);
cout << foo << endl;
return 0;
}

View file

@ -0,0 +1,36 @@
/* Demonstrate toupper and tolower for
standard C strings.
This does not work for multibyte character sets. */
#include <ctype.h>
#include <stdio.h>
/* upper-cases s in place */
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
/* lower-cases s in place */
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}

View file

@ -0,0 +1,4 @@
string(TOUPPER alphaBETA s)
message(STATUS "Uppercase: ${s}")
string(TOLOWER alphaBETA s)
message(STATUS "Lowercase: ${s}")

View file

@ -0,0 +1,3 @@
(def string "alphaBETA")
(println (.toUpperCase string))
(println (.toLowerCase string))

View file

@ -0,0 +1,2 @@
<cfset upper = UCase("alphaBETA")>
<cfset lower = LCase("alphaBETA")>

View file

@ -0,0 +1,3 @@
<cfset string = "alphaBETA">
<cfset upper = UCase(string)>
<cfset lower = LCase(string)>

View file

@ -0,0 +1,2 @@
CL-USER> (string-upcase "alphaBETA")
"ALPHABETA"

View file

@ -0,0 +1,2 @@
CL-USER> (string-downcase "alphaBETA")
"alphabeta"

View file

@ -0,0 +1,7 @@
import std.stdio, std.string;
void main() {
auto s = "alphaBETA";
writeln(s.toUpper());
writeln(s.toLower());
}

View file

@ -0,0 +1,2 @@
PrintLn(UpperCase('alphaBETA'));
PrintLn(LowerCase('alphaBETA'));

View file

@ -0,0 +1,2 @@
writeln(uppercase('alphaBETA'));
writeln(lowercase('alphaBETA'));

View file

@ -0,0 +1,2 @@
["alphaBETA".toUpperCase(),
"alphaBETA".toLowerCase()]

View file

@ -0,0 +1,2 @@
string:to_upper("alphaBETA").
string:to_lower("alphaBETA").

View file

@ -0,0 +1,4 @@
"alphaBETA" >lower ! "alphabeta"
"alphaBETA" >upper ! "ALPHABETA"
"alphaBETA" >title ! "Alphabeta"
"ß" >case-fold ! "ss"

View file

@ -0,0 +1,2 @@
printl("alphaBETA".lower())
printl("alphaBETA".upper())

View file

@ -0,0 +1,10 @@
fansh> a := "alphaBETA"
alphaBETA
fansh> a.upper // convert whole string to upper case
ALPHABETA
fansh> a.lower // convert whole string to lower case
alphabeta
fansh> a.capitalize // make sure first letter is capital
AlphaBETA
fansh> "BETAalpha".decapitalize // make sure first letter is not capital
bETAalpha

View file

@ -0,0 +1,38 @@
program example
implicit none
character(9) :: teststring = "alphaBETA"
call To_upper(teststring)
write(*,*) teststring
call To_lower(teststring)
write(*,*) teststring
contains
subroutine To_upper(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("a":"z")
str(i:i) = achar(iachar(str(i:i))-32)
end select
end do
end subroutine To_upper
subroutine To_lower(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("A":"Z")
str(i:i) = achar(iachar(str(i:i))+32)
end select
end do
end subroutine To_Lower
end program example

View file

@ -0,0 +1,8 @@
#define cases
{
x = 'alphaBETA';
y = string_upper(x); // returns ALPHABETA
z = string_lower(x); // returns alphabeta
show_message(y);
show_message(z);
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj") // should render similar to DZLjnj
}
func show(s string) {
fmt.Println("\nstring: ", s, "len:", utf8.RuneCountInString(s))
fmt.Println("All upper case: ", strings.ToUpper(s)) // DZLJNJ
fmt.Println("All lower case: ", strings.ToLower(s)) // dzljnj
fmt.Println("All title case: ", strings.ToTitle(s)) // DzLjNj
// notice Title() only modifies first letters of words
// non-first letters keep their case.
fmt.Println("Title words: ", strings.Title(s)) // Dzljnj
fmt.Println("Swapping case: ", strings.Map(unicode.SimpleFold, s))
}

View file

@ -0,0 +1,4 @@
def str = 'alphaBETA'
println str.toUpperCase()
println str.toLowerCase()

View file

@ -0,0 +1,6 @@
import Data.Char
s = "alphaBETA"
lower = map toLower s
upper = map toUpper s

View file

@ -0,0 +1,4 @@
CHARACTER str = "alphaBETA"
EDIT(Text=str, UpperCase=LEN(str))
EDIT(Text=str, LowerCase=LEN(str))
EDIT(Text=str, UpperCase=1)

View file

@ -0,0 +1,4 @@
procedure main()
write(map("alphaBETA"))
write(map("alphaBETA",&lcase,&ucase))
end

View file

@ -0,0 +1,4 @@
toupper 'alphaBETA'
ALPHABETA
tolower 'alphaBETA'
alphabeta

View file

@ -0,0 +1,2 @@
upper=: {&((65+i.26) +&32@[} i.256)&.(a.&i.)
lower=: {&((97+i.26) -&32@[} i.256)&.(a.&i.)

View file

@ -0,0 +1,4 @@
upper 'alphaBETA'
ALPHABETA
lower 'alphaBETA'
alphabeta

View file

@ -0,0 +1,6 @@
String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
//Also works with non-English characters with no modification
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase()); //does not transalate "SS" to "ß"

View file

@ -0,0 +1,2 @@
alert( "alphaBETA".toUpperCase() );
alert( "alphaBETA".toLowerCase() );

View file

@ -0,0 +1,3 @@
var string = "alphaBETA";
var uppercase = string.toUpperCase();
var lowercase = string.toLowerCase();

View file

@ -0,0 +1,7 @@
input$ ="alphaBETA"
print input$
print upper$( input$)
print lower$( input$)
end

View file

@ -0,0 +1,3 @@
str = "alphaBETA"
print( string.upper(str) )
print( string.lower(str) )

View file

@ -0,0 +1,6 @@
define(`upcase', `translit(`$*', `a-z', `A-Z')')
define(`downcase', `translit(`$*', `A-Z', `a-z')')
define(`x',`alphaBETA')
upcase(x)
downcase(x)

View file

@ -0,0 +1,11 @@
>> upper('alphaBETA')
ans =
ALPHABETA
>> lower('alphaBETA')
ans =
alphabeta

View file

@ -0,0 +1,3 @@
str = "alphaBETA"
print (toUpper str)
print (toLower str)

View file

@ -0,0 +1,7 @@
STRCASE(S)
SET UP="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
SET LO="abcdefghijklmnopqrstuvwxyz"
WRITE !,"Given: "_S
WRITE !,"Upper: "_$TRANSLATE(S,LO,UP)
WRITE !,"Lower: "_$TRANSLATE(S,UP,LO)
QUIT

View file

@ -0,0 +1,3 @@
str="alphaBETA";
ToUpperCase[str]
ToLowerCase[str]

View file

@ -0,0 +1,16 @@
:- module string_case.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module list, string.
main(!IO) :-
S = "alphaBETA",
io.format("uppercase : %s\n", [s(to_upper(S))], !IO),
io.format("lowercase : %s\n", [s(to_lower(S))], !IO),
io.format("capitalize first: %s\n", [s(capitalize_first(S))], !IO).
% We can use uncaptitalize_first/1 to ensure the first character in a
% string is lower-case.

View file

@ -0,0 +1,34 @@
vardef isbetween(expr a, i, f) =
if string a:
if (ASCII(a) >= ASCII(i)) and (ASCII(a) <= ASCII(f)):
true
else:
false
fi
else:
false
fi enddef;
vardef toupper(expr s) =
save ?; string ?; ? := ""; d := ASCII"A" - ASCII"a";
for i = 0 upto length(s)-1:
if isbetween(substring(i, i+1) of s, "a", "z"):
? := ? & char(ASCII(substring(i,i+1) of s) + d)
else:
? := ? & substring(i, i+1) of s
fi;
endfor
?
enddef;
vardef tolower(expr s) =
save ?; string ?; ? := ""; d := ASCII"a" - ASCII"A";
for i = 0 upto length(s)-1:
if isbetween(substring(i, i+1) of s, "A", "Z"):
? := ? & char(ASCII(substring(i,i+1) of s) + d)
else:
? := ? & substring(i, i+1) of s
fi;
endfor
?
enddef;

View file

@ -0,0 +1,4 @@
message toupper("alphaBETA");
message tolower("alphaBETA");
end

View file

@ -0,0 +1,30 @@
MODULE TextCase EXPORTS Main;
IMPORT IO, Text, ASCII;
PROCEDURE Upper(txt: TEXT): TEXT =
VAR
len := Text.Length(txt);
res := "";
BEGIN
FOR i := 0 TO len - 1 DO
res := Text.Cat(res, Text.FromChar(ASCII.Upper[Text.GetChar(txt, i)]));
END;
RETURN res;
END Upper;
PROCEDURE Lower(txt: TEXT): TEXT =
VAR
len := Text.Length(txt);
res := "";
BEGIN
FOR i := 0 TO len - 1 DO
res := Text.Cat(res, Text.FromChar(ASCII.Lower[Text.GetChar(txt, i)]));
END;
RETURN res;
END Lower;
BEGIN
IO.Put(Upper("alphaBETA\n"));
IO.Put(Lower("alphaBETA\n"));
END TextCase.

View file

@ -0,0 +1,15 @@
using System.Console;
using System.Globalization;
module StringCase
{
Main() : void
{
def alpha = "alphaBETA";
WriteLine(alpha.ToUpper());
WriteLine(alpha.ToLower());
WriteLine(CultureInfo.CurrentCulture.TextInfo.ToTitleCase("exAmpLe sTrinG"));
}
}

View file

@ -0,0 +1,9 @@
/* NetRexx */
options replace format comments java crossref savelog symbols
abc = 'alphaBETA'
say abc.upper
say abc.lower
say abc.upper(1, 1) -- capitalize 1st character

View file

@ -0,0 +1,2 @@
(upper-case "alphaBETA")
(lower-case "alphaBETA")

View file

@ -0,0 +1,4 @@
toupper 'alphaBETA'
=ALPHABETA
tolower 'alphaBETA'
=alphabeta

View file

@ -0,0 +1,7 @@
let () =
let str = "alphaBETA" in
print_endline (String.uppercase str); (* ALPHABETA *)
print_endline (String.lowercase str); (* alphabeta *)
print_endline (String.capitalize str); (* AlphaBETA *)
;;

View file

@ -0,0 +1,3 @@
string := "alphaBETA";
string->ToUpper()->PrintLine();
string->ToLower()->PrintLine();

View file

@ -0,0 +1,4 @@
NSLog(@"%@", [@"alphaBETA" uppercaseString]);
NSLog(@"%@", [@"alphaBETA" lowercaseString]);
NSLog(@"%@", [@"foO BAr" capitalizedString]); // "Foo Bar"

View file

@ -0,0 +1,5 @@
s = "alphaBETA";
slc = tolower(s);
suc = toupper(s);
disp(slc);
disp(suc);

View file

@ -0,0 +1,2 @@
caps("alphaBETA")
lc("alphaBETA")

View file

@ -0,0 +1,5 @@
string s="alphaBETA"
print lcase(s) " "+
ucase(s) " "+
ucase(left(s,1))+mid(s,2) 'capitalised

View file

@ -0,0 +1,5 @@
declare
Str = "alphaBETA"
in
{System.showInfo {Map Str Char.toUpper}}
{System.showInfo {Map Str Char.toLower}}

View file

@ -0,0 +1,4 @@
declare
[StringX] = {Link ['x-oz://system/String.ozf']}
in
{System.showInfo {StringX.capitalize "alphaBETA"}} %% prints "AlphaBETA"

View file

@ -0,0 +1,8 @@
$str = "alphaBETA";
echo strtoupper($str), "\n"; // ALPHABETA
echo strtolower($str), "\n"; // alphabeta
echo ucfirst($str), "\n"; // AlphaBETA
echo lcfirst("FOObar"), "\n"; // fOObar
echo ucwords("foO baR baZ"), "\n"; // FoO BaR BaZ
echo lcwords("FOo BAr BAz"), "\n"; // fOo bAr bAz

View file

@ -0,0 +1,4 @@
declare s character (20) varying initial ('alphaBETA');
put skip list (uppercase(s));
put skip list (lowercase(s));

View file

@ -0,0 +1,5 @@
/* An alternative to the above, which might be used if some */
/* non-standard conversion is required, is shown for */
/* converting to upper case: */
put skip list ( translate(s, 'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ') );

View file

@ -0,0 +1,10 @@
declare
vc VARCHAR2(40) := 'alphaBETA';
ivc VARCHAR2(40);
lvc VARCHAR2(40);
uvc VARCHAR2(40);
begin
ivc := INITCAP(vc); -- 'Alphabeta'
lvc := LOWER(vc); -- 'alphabeta'
uvc := UPPER(vc); -- 'ALPHABETA'
end;

View file

@ -0,0 +1,9 @@
my $word = "alpha BETA" ;
say uc $word; # all uppercase (subroutine call)
say $word.uc; # all uppercase (method call)
# from now on we use only method calls as examples
say $word.lc; # all lowercase
say $word.tc; # first letter titlecase
say $word.tclc; # first letter titlecase, rest lowercase
say $word.tcuc; # first letter titlecase, rest uppercase
say $word.wordcase; # capitalize each word

View file

@ -0,0 +1,7 @@
my $string = "alphaBETA";
print uc($string), "\n"; # => "ALPHABETA"
print lc($string), "\n"; # => "alphabeta"
$string =~ tr/[a-z][A-Z]/[A-Z][a-z]/; print "$string\n"; # => ALPHAbeta
print ucfirst($string), "\n"; # => "AlphaBETA"
print lcfirst("FOObar"), "\n"; # => "fOObar"

View file

@ -0,0 +1,3 @@
(let Str "alphaBETA"
(prinl (uppc Str))
(prinl (lowc Str)) )

View file

@ -0,0 +1,3 @@
lvars str = 'alphaBETA';
lowertoupper(str) =>
uppertolower(str) =>

View file

@ -0,0 +1,3 @@
$string = 'alphaBETA'
$lower = $string.ToLower()
$upper = $string.ToUpper()

View file

@ -0,0 +1,5 @@
<@ ENU$$$LSTPSTLITLIT>UPP|
[<@ SAYELTLST>...</@>] <@ SAYHLPELTLST>...</@><@ DEFKEYELTLST>__SuperMacro|...</@>
<@ SAY&&&LIT>alphaBETA</@>
</@>

View file

@ -0,0 +1,5 @@
<# ENUMERATION LAMBDA LIST PEERSET LITERAL LITERAL>UPP|
[<# SAY ELEMENT LIST>...</#>] <# SAY HELP ELEMENT LIST>...</#><# DEFINE KEYWORD ELEMENT LIST>__SuperMacro|...</#>
<# SAY SUPERMACRO LITERAL>alphaBETA</#>
</#>

View file

@ -0,0 +1,3 @@
s$ = "alphaBETA"
upper$ = UCase(s$) ;uppercase
lower$ = LCase(s$) ;lowercase

View file

@ -0,0 +1,11 @@
s = "alphaBETA"
print s.upper() # => "ALPHABETA"
print s.lower() # => "alphabeta"
print s.swapcase() # => "ALPHAbeta"
print "fOo bAR".capitalize() # => "Foo bar"
print "fOo bAR".title() # => "Foo Bar"
import string
print string.capwords("fOo bAR") # => "Foo Bar"

View file

@ -0,0 +1,2 @@
print "foo's bar".title() # => "Foo'S Bar"
print string.capwords("foo's bar") # => "Foo's Bar"

View file

@ -0,0 +1,3 @@
str <- "alphaBETA"
toupper(str)
tolower(str)

View file

@ -0,0 +1,3 @@
print ["Original: " original: "alphaBETA"]
print ["Uppercase:" uppercase original]
print ["Lowercase:" lowercase original]

View file

@ -0,0 +1,6 @@
abc = "abcdefghijklmnopqrstuvwxyz" /*define all the lowercase letters*/
abcU = translate(abc) /* " " " uppercase " */
x = 'alphaBETA' /*define string to a REXX variable*/
y = translate(x) /*uppercase X and store it───► Y*/
z = translate(x, abc, abcU) /*tran uppercase──►lowercase chars*/

View file

@ -0,0 +1,5 @@
x = "alphaBETA" /*define string to a REXX variable*/
parse upper var x y /*uppercase X and store it───► Y*/
parse lower var x z /*lowercase X " " " ───► Z*/
/*Some REXXes don't support the LOWER option for the PARSE command.*/

View file

@ -0,0 +1,6 @@
x = 'alphaBETA' /*define string to a REXX variable*/
y = upper(x) /*uppercase X and store it───► Y*/
z = lower(x) /*lowercase X " " " ───► Z*/
/*Some REXXes don't support the UPPER and */
/* LOWER BIFs (built-in functions). */

View file

@ -0,0 +1,5 @@
x = "alphaBETA" /*define string to a REXX variable*/
y=x; upper y /*uppercase X and store it───► Y*/
parse lower var x z /*lowercase Y " " " ───► Z*/
/*Some REXXes don't support the LOWER option for the PARSE command.*/

View file

@ -0,0 +1,17 @@
/*REXX pgm capitalizes each word in string, maintains imbedded blanks.*/
x= "alef bet gimel dalet he vav zayin het tet yod kaf lamed mem nun samekh",
"ayin pe tzadi qof resh shin tav." /*"old" spelling Hebrew letters. */
y= capitalize(x) /*capitalize each word in string.*/
say x /*show original string of words. */
say y /*show the capitalized words. */
exit /*stick a fork in it, we're done.*/
/*───────────────────────────────────CAPITALIZE subroutine──────────────*/
capitalize: procedure; parse arg z; $=' 'z /*prefix with a blank.*/
abc = "abcdefghijklmnopqrstuvwxyz" /*define all lowercase letters. */
do j=1 for 26 /*process each letter in alphabet*/
_=' 'substr(abc,j,1); _U=_; upper _U /*get a lower and upper letter. */
$ = changestr(_, $, _U) /*maybe capitalize some word(s). */
end /*j*/
return substr($,2) /*capitalized words, -1st blank.*/

View file

@ -0,0 +1,9 @@
/*REXX pgm swaps letter case of a string: lower──►upper & upper──►lower.*/
abc = "abcdefghijklmnopqrstuvwxyz" /*define all the lowercase letters*/
abcU = translate(abc) /* " " " uppercase " */
x = 'alphaBETA' /*define string to a REXX variable*/
y = translate(x,abc||abcU,abcU||abc) /*swap case of X store it ───► Y*/
say x
say y
/*stick a fork in it, we're done.*/

View file

@ -0,0 +1,11 @@
x='alphaBETA'; Say ' x='||x
Say 'three ways to uppercase'
u1=translate(x); Say ' u1='u1
u2=upper(x); Say ' u2='u2
parse upper var x u3; Say ' u3='u3
abc ='abcdefghijklmnopqrstuvwxyz'
abcu=translate(abc); Say 'three ways to lowercase'
l1=translate(x,abc,abcu); Say ' l1='l1
l2=lower(x); Say ' l2='l2
parse lower var x l3; Say ' l3='l3

View file

@ -0,0 +1,8 @@
uppercase: /*courtesy Gerard Schildberger */
return translate(changestr("ß",translate(arg(1),'ÄÖÜ',"äöü"),'SS'))
uppercase2: Procedure
Parse Arg a
a=translate(arg(1),'ÄÖÜ',"äöü") /* translate lowercase umlaute */
a=changestr("ß",a,'SS') /* replace ß with SS */
return translate(a) /* translate lowercase letters */

View file

@ -0,0 +1,2 @@
'alphaBETA' upper
'alhpaBETA' lower

View file

@ -0,0 +1,3 @@
with strings'
"alphaBETA" toUpper puts
"alphaBETA" toLower puts

View file

@ -0,0 +1,5 @@
"alphaBETA".downcase # => "alphabeta"
"alphaBETA".upcase # => "ALPHABETA"
"alphaBETA".swapcase # => "ALPHAbeta"
"alphaBETA".capitalize # => "Alphabeta"

View file

@ -0,0 +1,5 @@
a$ ="alphaBETA"
print a$ '=> alphaBETA
print upper$(a$) '=> ALPHABETA
print lower$(a$) '=> alphabeta

View file

@ -0,0 +1,26 @@
define('uc(str)') :(uc_end)
uc uc = replace(str,&lcase,&ucase) :(return)
uc_end
define('lc(str)') :(lc_end)
lc lc = replace(str,&ucase,&lcase) :(return)
lc_end
define('ucfirst(str)ch') :(ucfirst_end)
ucfirst str len(1) . ch = uc(ch)
ucfirst = str :(return)
ucfirst_end
define('swapc(str)') :(swapc_end)
swapc str = replace(str,&ucase &lcase, &lcase &ucase)
swapc = str :(return)
swapc_end
* # Test and display
str = 'alphaBETA'
output = str
output = lc(str)
output = uc(str)
output = ucfirst(str)
output = swapc(str)
end

Some files were not shown because too many files have changed in this diff Show more