Jump to content

Integer comparison: Difference between revisions

Line 1,017:
end
handle Bind => print "Invalid number entered!\n"</lang>
A more idiomatic and less error-prone way to do it in SML would be to use a compare function that returns type <tt>order</tt>, which is either LESS, GREATER, or EQUAL:
<lang sml>fun myCompare (a, b) = case Int.compare (a, b) of
LESS => "A is less than B"
| GREATER => "A is greater than B"
| EQUAL => "A equals B"</lang>
 
=={{header|Tcl}}==
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.