String comparison: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) (Undo revision 324768 by Drkameleon (talk)) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 28: | Line 28: | ||
{{Template:Strings}} |
{{Template:Strings}} |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
{{trans|Python}} |
|||
Note: 11l does not have case-insensitive string comparison operators, instead use <code>name.upper()</code> or <code>name.lower()</code> to coerce strings to the same case and compare the results. |
|||
<lang 11l>F compare(a, b) |
|||
I a < b {print(‘'#.' is strictly less than '#.'’.format(a, b))} |
|||
I a <= b {print(‘'#.' is less than or equal to '#.'’.format(a, b))} |
|||
I a > b {print(‘'#.' is strictly greater than '#.'’.format(a, b))} |
|||
I a >= b {print(‘'#.' is greater than or equal to '#.'’.format(a, b))} |
|||
I a == b {print(‘'#.' is equal to '#.'’.format(a, b))} |
|||
I a != b {print(‘'#.' is not equal to '#.'’.format(a, b))} |
|||
compare(‘YUP’, ‘YUP’) |
|||
compare(‘BALL’, ‘BELL’) |
|||
compare(‘24’, ‘123’)</lang> |
|||
{{out}} |
|||
<pre> |
|||
'YUP' is less than or equal to 'YUP' |
|||
'YUP' is greater than or equal to 'YUP' |
|||
'YUP' is equal to 'YUP' |
|||
'BALL' is strictly less than 'BELL' |
|||
'BALL' is less than or equal to 'BELL' |
|||
'BALL' is not equal to 'BELL' |
|||
'24' is strictly greater than '123' |
|||
'24' is greater than or equal to '123' |
|||
'24' is not equal to '123' |
|||
</pre> |
|||
=={{header|AArch64 Assembly}}== |
=={{header|AArch64 Assembly}}== |
||
Line 213: | Line 243: | ||
.include "../includeARM64.inc" |
.include "../includeARM64.inc" |
||
</lang> |
</lang> |
||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
Ada uses the usual comparison operators ("=" for equality, "/=" for not being equal, etc.) for strings. One uses the same comparison operators to compare variables of other types (integers, floating point numbers, etc.). |
Ada uses the usual comparison operators ("=" for equality, "/=" for not being equal, etc.) for strings. One uses the same comparison operators to compare variables of other types (integers, floating point numbers, etc.). |