Extend your language: Difference between revisions

Line 3,324:
a = 0, b = 1 => second positive
a = 0, b = 0 => neither positive
</pre>
 
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
In RPL, the IFTE function returns either the first or the second level of the stack, depending on whether the third level is false or true respectively. The extension of this concept to the one proposed by the task is quite simple, and allows a true quadruple branching, as shown in the demonstration.
≪ 4 ROLL SWAP 4 ROLLD 4 →LIST
SWAP SIGN 2 * ROT SIGN + 1 + GET ≫
‘IF2TE’ STO
 
1 1 "Both" "First" "Second" "None" IF2TE
0 1 "Both" "First" "Second" "None" IF2TE
{{out}}
<pre>
2: "Both"
1: "Second"
</pre>
===Quadruple branching example===
≪ → hour min
≪ min 30 MOD min 30 <
≪ min →STR " PAST " + hour →STR + ≫
≪ 60 min - →STR " TO " + hour 1 + →STR + ≫
≪ hour →STR " PRECISELY" + ≫
≪ "HALF PAST " hour →STR + ≫
IF2TE EVAL
'SAYTIME' STO
 
3 25 SAYTIME
1 55 SAYTIME
6 30 SAYTIME
7 0 SAYTIME
{{out}}
<pre>
4: "25 PAST 3"
3: "5 TO 2"
2: "HALF PAST 6"
1: "7 PRECISELY"
</pre>
 
1,150

edits