Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -1,4 +1,4 @@
|
|||
STRING a := "abc ", b := "ABC ";
|
||||
STRING sa := "abc ", sb := "ABC ";
|
||||
|
||||
# when comparing strings, Algol 68 ignores trailing blanks #
|
||||
# so e.g. "a" = "a " is true #
|
||||
|
|
@ -8,15 +8,15 @@ PROC test = ( BOOL condition, STRING message )VOID:
|
|||
IF condition THEN print( ( message, newline ) ) FI;
|
||||
|
||||
# equality? #
|
||||
test( a = b, "a = b" );
|
||||
test( sa = sb, "sa = sb" );
|
||||
# inequality? #
|
||||
test( a /= b, "a not = b" );
|
||||
test( sa /= sb, "sa not = sb" );
|
||||
|
||||
# lexically ordered before? #
|
||||
test( a < b, "a < b" );
|
||||
test( sa < sb, "sa < sb" );
|
||||
|
||||
# lexically ordered after? #
|
||||
test( a > b, "a > b" );
|
||||
test( sa >s b, "sa > sb" );
|
||||
|
||||
# Algol 68's builtin string comparison operators are case-sensitive. #
|
||||
# To perform case insensitive comparisons, procedures or operators #
|
||||
|
|
@ -50,7 +50,7 @@ PROC caseless comparison = ( STRING a, b )INT:
|
|||
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)" );
|
||||
test( equal ignoring case( sa, sb ), "sa = sb (ignoring case)" );
|
||||
|
||||
|
||||
# Algol 68 is strongly typed - strings cannot be compared to e.g. integers #
|
||||
|
|
@ -61,7 +61,7 @@ test( equal ignoring case( a, b ), "a = b (ignoring case)" );
|
|||
|
||||
# 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" );
|
||||
test( sa <= sb, "sa <= sb" );
|
||||
test( sa >= sb, "sa >= sb" )
|
||||
|
||||
# there are no other forms of string comparison builtin to Algol 68 #
|
||||
|
|
|
|||
15
Task/String-comparison/EMal/string-comparison.emal
Normal file
15
Task/String-comparison/EMal/string-comparison.emal
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
fun compare ← void by text a, text b
|
||||
writeLine("Comparing `", a, "` and `", b, "`:")
|
||||
text la ← a.lower()
|
||||
text lb ← b.lower()
|
||||
writeLine(" `", a, "` æ `", b, "` case sensitively: ", a æ b, ", case insensitively: ", la æ lb)
|
||||
writeLine(" `", a, "` ≠ `", b, "` case sensitively: ", a ≠ b, ", case insensitively: ", la ≠ lb)
|
||||
writeLine(" `", a, "` ◇ `", b, "` case sensitively: ", a ◇ b, ", case insensitively: ", la ◇ lb)
|
||||
writeLine(" `", a, "` < `", b, "` case sensitively: ", a < b, ", case insensitively: ", la < lb)
|
||||
writeLine(" `", a, "` > `", b, "` case sensitively: ", a > b, ", case insensitively: ", la > lb)
|
||||
writeLine(" `", a, "` ≤ `", b, "` case sensitively: ", a ≤ b, ", case insensitively: ", la ≤ lb)
|
||||
writeLine(" `", a, "` ≥ `", b, "` case sensitively: ", a ≥ b, ", case insensitively: ", la ≥ lb)
|
||||
end
|
||||
List samples ← Pair[text%text("Hello" ⇒ "Hello"), text%text("5" ⇒ "5.0"),
|
||||
text%text("java" ⇒ "Java"), text%text("ĴÃVÁ" ⇒ "ĴÃVÁ"), text%text("ĴÃVÁ" ⇒ "ĵãvá")]
|
||||
samples.list(<Pair pair|compare(pair.key, pair.value))
|
||||
11
Task/String-comparison/Ed/string-comparison.ed
Normal file
11
Task/String-comparison/Ed/string-comparison.ed
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# by Artyom Bologov
|
||||
H
|
||||
1s/$/|/
|
||||
,j
|
||||
t0
|
||||
1s/^\(.*\)|\1$/Strings are equal case-sensitively/
|
||||
1v/Strings are equal case-sensitively/s/.*/Strings are not equal case-sensitively/
|
||||
2s/^\(.*\)|\1$/Strings are equal case-insensitively/i
|
||||
2v/Strings are equal case-insensitively/s/.*/Strings are not equal case-insensitively/
|
||||
,p
|
||||
Q
|
||||
Loading…
Add table
Add a link
Reference in a new issue