String comparison: Difference between revisions

added swift
(add "Related tasks" link)
(added swift)
Line 1,574:
 
Original source: [http://seed7.sourceforge.net/algorith/string.htm#cmpNumeric]
 
=={{Header|Swift}}==
<lang swift>func compare (a: String, b: String) {
if a == b {
println("'\(a)' and '\(b)' are lexically equal.")
}
if a != b {
println("'\(a)' and '\(b)' are not lexically equal.")
}
if a < b {
println("'\(a)' is lexically before '\(b)'.")
}
if a > b {
println("'\(a)' is lexically after '\(b)'.")
}
if a >= b {
println("'\(a)' is not lexically before '\(b)'.")
}
if a <= b {
println("'\(a)' is not lexically after '\(b)'.")
}
}
compare("cat", "dog")</lang>
{{Out}}
<pre>
'cat' and 'dog' are not lexically equal.
'cat' is lexically before 'dog'.
'cat' is not lexically after 'dog'.
</pre>
 
=={{header|Tcl}}==
Anonymous user