Time for an 2014 update…

This commit is contained in:
Ingy döt Net 2014-01-17 05:32:22 +00:00
parent 372c577f83
commit 09687c4926
2520 changed files with 34227 additions and 7318 deletions

View file

@ -0,0 +1,12 @@
IF s1 == s2
? "The strings are equal"
ENDIF
IF .NOT. (s1 == s2)
? "The strings are not equal"
ENDIF
IF s1 > s2
? "s2 is lexically ordered before than s1"
ENDIF
IF s1 < s2
? "s2 is lexically ordered after than s1"
ENDIF

View file

@ -0,0 +1,3 @@
IF Upper(s1) == Upper(s2)
? "The strings are equal"
ENDIF

View file

@ -1,17 +1,37 @@
animal = 'dog'
if animal = 'cat' then say animal "is lexically equal to cat"
if animal \= 'cat' then say animal "is not lexically equal cat"
if animal > 'cat' then say animal "is lexically higher than cat"
if animal < 'cat' then say animal "is lexically lower than cat"
if animal >= 'cat' then say animal "is not lexically lower than cat"
if animal <= 'cat' then say animal "is not lexically higher than cat"
/*REXX program shows different ways to compare two character strings.*/
say 'This is an ' word('ASCII EBCDIC', 1+(1=='f1')) ' system.'
say
cat = 'cat'
animal = 'dog'
if animal = cat then say $(animal) "is lexically equal to" $(cat)
if animal \= cat then say $(animal) "is not lexically equal to" $(cat)
if animal > cat then say $(animal) "is lexically higher than" $(cat)
if animal < cat then say $(animal) "is lexically lower than" $(cat)
if animal > cat then say $(animal) "is not lexically lower than" $(cat)
if animal < cat then say $(animal) "is not lexically higher than" $(cat)
/*The above comparative operators do not consider */
/*leading and trailing whitespace when making comparisons.*/
/*──── [↑] The above comparative operators don't */
/*────consider any leading and/or trailing white- */
/*────space when making comparisons, but the case */
/*────is honored (uppercase, lowercase). */
if ' cat ' = 'cat' then say "this will print because whitespace is stripped"
fatcat=' cat ' /*pad the cat with leading and trailing blanks. */
if fatcat = cat then say $(fatcat) " is equal to" $(cat)
/*To consider any whitespace in a comparison, */
/*we need to use strict comparative operators.*/
/*────To consider any whitespace in a comparison, */
/*────we need to use strict comparative operators.*/
if ' cat ' == 'cat' then say "this will not print because comparison is strict"
if fatcat == cat then say $(fatcat) "is strictly equal to" $(cat)
/*────To perform caseless comparisons, the easiest*/
/*────method would be to uppercase a copy of both */
/*────operands. Uppercasing is only done for the */
/*────Latin (or Roman) alphabet in REXX. [↓] */
kat='cAt'
if caselessComp(cat,kat) then say $(cat) 'and' $(kat) "are equal caseless"
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────$ subroutine────────────────────────*/
$: return ''arg(1)'' /*bracket the string with ──►α◄──*/
/*──────────────────────────────────CASELESSCOMP subroutine─────────────*/
caselessComp: procedure; arg a,b /*ARG uppercases the A & B args.*/
return a==b /*if exactly equal, return 1. */

View file

@ -1,5 +1,5 @@
method_names = [:==,:!=, :>, :>=, :<, :<=, :<=>, :casecmp]
[["YUP", "YUP"], ["YUP", "Yup"], ["bot","bat"],["zz", "aaa"]].each do |(str1, str2)|
method_names.each{|m| print str1," ", m," ", str2,"\t", str1.send(m, str2),"\n"}
[["YUP", "YUP"], ["YUP", "Yup"], ["bot","bat"], ["aaa", "zz"]].each do |str1, str2|
method_names.each{|m| puts "%s %s %s\t%s" % [str1, m, str2, str1.send(m, str2)]}
puts
end