String comparison: Difference between revisions

Content added Content deleted
m (added whitespace before the TOC (table of contents), added a ;Related tasks; (bold) header.)
Line 9: Line 9:
* How to achieve both case sensitive comparisons and case insensitive comparisons within the language
* How to achieve both case sensitive comparisons and case insensitive comparisons within the language
* How the language handles comparison of numeric strings if these are not treated lexically
* How the language handles comparison of numeric strings if these are not treated lexically
* Demonstrate any other kinds of string comparisons that the language provides, particularly as it relates to your type system. For example, you might demonstrate the difference between generic/polymorphic comparison and coercive/allomorphic comparison if your language supports such a distinction.
* Demonstrate any other kinds of string comparisons that the language provides, particularly as it relates to your type system.   For example, you might demonstrate the difference between generic/polymorphic comparison and coercive/allomorphic comparison if your language supports such a distinction.


<br>
<br>
Here "generic/polymorphic" comparison means that the function or operator you're using doesn't always do string comparison, but bends the actual semantics of the comparison depending on the types one or both arguments; with such an operator, you achieve string comparison only if the arguments are sufficiently string-like in type or appearance. In contrast, a "coercive/allomorphic" comparison function or operator has fixed string-comparison semantics regardless of the argument type; instead of the operator bending, it's the arguments that are forced to bend instead and behave like strings if they can, and the operator simply fails if the arguments cannot be viewed somehow as strings. A language may have one or both of these kinds of operators; see the Perl 6 entry for an example of a language with both kinds of operators.
Here "generic/polymorphic" comparison means that the function or operator you're using doesn't always do string comparison, but bends the actual semantics of the comparison depending on the types one or both arguments; with such an operator, you achieve string comparison only if the arguments are sufficiently string-like in type or appearance.


In contrast, a "coercive/allomorphic" comparison function or operator has fixed string-comparison semantics regardless of the argument type; &nbsp; instead of the operator bending, it's the arguments that are forced to bend instead and behave like strings if they can, &nbsp; and the operator simply fails if the arguments cannot be viewed somehow as strings. &nbsp; A language may have one or both of these kinds of operators; &nbsp; see the Perl 6 entry for an example of a language with both kinds of operators.
'''See also:'''<!-- Note that this part might go away, as it is handled by the “basic data operation” template -->
* [[Integer comparison]]
* [[String matching]]
* [[Compare a list of strings]]



;Related tasks:
* &nbsp; [[Integer comparison]]
* &nbsp; [[String matching]]
* &nbsp; [[Compare a list of strings]]
<br><br>


=={{header|Ada}}==
=={{header|Ada}}==