Integer comparison: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
No edit summary
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(2 intermediate revisions by 2 users not shown)
Line 2,021:
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Integer_comparison}}
 
'''Solution'''
 
Fōrmulæ has an intrinsic expression for [[wp:Three-way_comparison|three-way comparison]] that works for integers and other types (decimal and rational numbers, strings, time expressions, etc). It returns expressions that flag one of the three possible results.
 
[[File:Fōrmulæ - Integer comparison 01.png]]
 
[[File:Fōrmulæ - Integer comparison 02.png]]
 
However, a simple function can be written for the requirement:
 
[[File:Fōrmulæ - Integer comparison 03.png]]
 
[[File:Fōrmulæ - Integer comparison 04.png]]
 
[[File:Fōrmulæ - Integer comparison 05.png]]
 
=={{header|Go}}==
Line 3,047 ⟶ 3,063:
Pop $0
FunctionEnd
</syntaxhighlight>
 
=={{header|Nu}}==
<syntaxhighlight lang="nu">
[First Second] | each {input $"($in) integer: "| into int} | [
[($in.0 < $in.1) "less than"]
[($in.0 == $in.1) "equal to"]
[($in.0 > $in.1) "greater than"]
] | each {if $in.0 {$"The first integer is ($in.1) the second integer."}} | str join "\n"
</syntaxhighlight>
 
Line 4,455 ⟶ 4,480:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">import "io" for Stdin, Stdout
 
System.print("Enter anything other than a number to quit at any time.\n")
9,485

edits