String comparison: Difference between revisions

Content added Content deleted
m (→‎{{header|NetRexx}}: make references "active")
(add Forth (can't collate or compare case-insensitive))
Line 379: Line 379:
BELL is greater than or equal to bELL (case insensitive)
BELL is greater than or equal to bELL (case insensitive)
BELL is equal to bELL (case insensitive)</pre>
BELL is equal to bELL (case insensitive)</pre>

=={{header|Forth}}==
The ANS Forth standard has the word COMPARE to lexically compare two strings, with the same behavior as the C standard library strcmp() function.

<lang Forth>: str-eq ( str len str len -- ? ) compare 0= ;
: str-neq ( str len str len -- ? ) compare 0<> ;
: str-lt ( str len str len -- ? ) compare 0< ;
: str-gt ( str len str len -- ? ) compare 0> ;
: str-le ( str len str len -- ? ) compare 0<= ;
: str-ge ( str len str len -- ? ) compare 0>= ;</lang>

Although many Forths allow case-insensitive lookup of ASCII dictionary names for function and variable names (FIND, SEARCH-WORDLIST), this capability is not exposed for other uses in a standard way.


=={{header|J}}==
=={{header|J}}==