Exponentiation with infix operators in (or operating on) the base: Difference between revisions

Undo revision 315342 by Thundergnat (talk) meh, not necessary
m (→‎{{header|Raku}}: add explanatory exposition)
(Undo revision 315342 by Thundergnat (talk) meh, not necessary)
Line 106:
 
say "\nEasily modified: custom loose infix exponentiation is looser (lower) precedence than unary negation.";
-> $x, $p { infix-loose-exp($x, $p) } for -5, 2, -5, 3, 5, 2, 5, 3;</lang>
 
say "\nNote that this detects the difference between unary prefix negation and infix subtraction.";
say "-5 - 5 ↑ 3 yields -130 not -1000: ", -5 - 5 ↑ 3;</lang>
{{out}}
<pre>Default precedence: infix exponentiation is tighter (higher) precedence than unary negation.
Line 121 ⟶ 118:
x = -5 p = 3 │ -x↑p = 125 │ -(x)↑p = 125 │ (-x)↑p = 125 │ -(x↑p) = 125
x = 5 p = 2 │ -x↑p = 25 │ -(x)↑p = 25 │ (-x)↑p = 25 │ -(x↑p) = -25
x = 5 p = 3 │ -x↑p = -125 │ -(x)↑p = -125 │ (-x)↑p = -125 │ -(x↑p) = -125</pre>
 
Note that this detects the difference between unary prefix negation and infix subtraction.
-5 - 5 ↑ 3 yields -130 not -1000: -130</pre>
 
=={{header|REXX}}==
10,343

edits