String comparison: Difference between revisions
Content added Content deleted
(Added Tailspin solution) |
Alpha bravo (talk | contribs) (Added AutoHotkey) |
||
Line 771: | Line 771: | ||
];</lang> |
];</lang> |
||
Avail is strongly-typed and the standard library's comparison functions do not admit mixed comparison between numerics and strings. Strings are immutable tuples of characters and are always compared by value -- few entities in Avail have identity so "object equality" is usually meaningless. |
Avail is strongly-typed and the standard library's comparison functions do not admit mixed comparison between numerics and strings. Strings are immutable tuples of characters and are always compared by value -- few entities in Avail have identity so "object equality" is usually meaningless. |
||
=={{header|AutoHotkey}}== |
|||
<lang AutoHotkey>exact_equality(a,b){ |
|||
return (a==b) |
|||
} |
|||
exact_inequality(a,b){ |
|||
return !(a==b) |
|||
} |
|||
equality(a,b){ |
|||
return (a=b) |
|||
} |
|||
inequality(a,b){ |
|||
return !(a=b) |
|||
} |
|||
ordered_before(a,b){ |
|||
return ("" a < "" b) |
|||
} |
|||
ordered_after(a,b){ |
|||
return ("" a > "" b) |
|||
}</lang> |
|||
Examples:<lang AutoHotkey>for a, b in {"alpha":"beta", "Gamma":"gamma", 100:5} |
|||
MsgBox % a " vs " b "`n" |
|||
. "exact_equality case sensitive : " exact_equality(a,b) "`n" |
|||
. "exact_inequality case sensitive :" exact_inequality(a,b) "`n" |
|||
. "equality case insensitive : " equality(a,b) "`n" |
|||
. "inequality case insensitive : " inequality(a,b) "`n" |
|||
. "ordered_before : " ordered_before(a,b) "`n" |
|||
. "ordered_after : " ordered_after(a,b) "`n"</lang> |
|||
{{out}} |
|||
<pre>100 vs 5 |
|||
exact_equality case sensitive : 0 |
|||
exact_inequality case sensitive :1 |
|||
equality case insensitive : 0 |
|||
inequality case insensitive : 1 |
|||
ordered_before : 1 |
|||
ordered_after : 0 |
|||
--------------------------- |
|||
alpha vs beta |
|||
exact_equality case sensitive : 0 |
|||
exact_inequality case sensitive :1 |
|||
equality case insensitive : 0 |
|||
inequality case insensitive : 1 |
|||
ordered_before : 1 |
|||
ordered_after : 0 |
|||
--------------------------- |
|||
Gamma vs gamma |
|||
exact_equality case sensitive : 0 |
|||
exact_inequality case sensitive :1 |
|||
equality case insensitive : 1 |
|||
inequality case insensitive : 0 |
|||
ordered_before : 0 |
|||
ordered_after : 0</pre> |
|||
=={{header|AWK}}== |
=={{header|AWK}}== |