March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -0,0 +1,3 @@
"hello" = "hello" *> equality
"helloo" <> "hello" *> inequality
"aello" < "hello" *> lexical ordering

View file

@ -0,0 +1,3 @@
FUNCTION STANDARD-COMPARE("hello", "hello") *> "="
FUNCTION STANDARD-COMPARE("aello", "hello") *> "<"
FUNCTION STANDARD-COMPARE("hello", "aello") *> ">"

View file

@ -0,0 +1,2 @@
"hello " = "hello" *> True
X"00" > X"0000" *> True

View file

@ -0,0 +1,14 @@
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

View file

@ -0,0 +1,25 @@
use v5.16; # ...for fc(), which does proper Unicode casefolding.
# With older Perl versions you can use lc() as a poor-man's substitute.
sub compare {
my ($a, $b) = @_;
my $A = "'$a'";
my $B = "'$b'";
print "$A and $B are lexically equal.\n" if $a eq $b;
print "$A and $B are not lexically equal.\n" if $a ne $b;
print "$A is lexically before $B.\n" if $a lt $b;
print "$A is lexically after $B.\n" if $a gt $b;
print "$A is not lexically before $B.\n" if $a ge $b;
print "$A is not lexically after $B.\n" if $a le $b;
print "The lexical relationship is: ", $a cmp $b, "\n";
print "The case-insensitive lexical relationship is: ", fc($a) cmp fc($b), "\n";
print "\n";
}
compare('Hello', 'Hello');
compare('5', '5.0');
compare('perl', 'Perl');

View file

@ -0,0 +1,14 @@
;; Comparing two strings for exact equality
(string=? "hello" "hello")
;; Comparing two strings for inequality
(not (string=? "hello" "Hello"))
;; Checking if the first string is lexically ordered before the second
(string<? "bar" "foo")
;; Checking if the first string is lexically ordered after the second
(string>? "foo" "bar")
;; case insensitive comparison
(string-ci=? "hello" "Hello")