Integer comparison: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) No edit summary |
(Added Quackery.) |
||
Line 3,071: | Line 3,071: | ||
In this case the use of a dispatch table is silly. However, more generally in Python the use of dispatch dictionaries or tables is often preferable to long chains of '''''elif'''' clauses in a condition statement. Python's support of classes and functions (including [[currying]], partial function support, and lambda expressions) as first class objects obviates the need for a "case" or "switch" statement. |
In this case the use of a dispatch table is silly. However, more generally in Python the use of dispatch dictionaries or tables is often preferable to long chains of '''''elif'''' clauses in a condition statement. Python's support of classes and functions (including [[currying]], partial function support, and lambda expressions) as first class objects obviates the need for a "case" or "switch" statement. |
||
=={{header|Quackery}}== |
|||
<lang Quackery>$ "Please enter two numbers separated by a space; " |
|||
input quackery cr |
|||
say "The first number is " |
|||
[ 2dup > iff [ say "larger than" ] done |
|||
2dup = iff [ say "equal to" ] done |
|||
2dup < if [ say "smaller than" ] ] |
|||
2drop |
|||
say " the second number." cr</lang> |
|||
{{out}} |
|||
Testing in the Quackery shell (REPL). |
|||
<pre>/O> $ "Please enter two numbers separated by a space; " |
|||
... input quackery cr |
|||
... say "The first number is " |
|||
... [ 2dup > iff [ say "larger than" ] done |
|||
... 2dup = iff [ say "equal to" ] done |
|||
... 2dup < if [ say "smaller than" ] ] |
|||
... 2drop |
|||
... say " the second number." cr |
|||
... |
|||
Please enter two numbers separated by a space; 4 2 |
|||
The first number is larger than the second number. |
|||
Stack empty.</pre> |
|||
=={{header|R}}== |
=={{header|R}}== |