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

(Add QB64)
Line 236:
</pre>
 
=={{header|J}}==
APLs use a negative sign distinguished from minus as a different character. Underscore followed by a number specifies a negative number. APLs also process the operations from right to left, evaluating parenthesized expressions when the interpreter comes to them. In J, unary plus returns complex conjugate, which won't affect the outcome of this experiment.
<pre>
format=: ''&$: :([: ; (a: , [: ":&.> [) ,. '{}' ([ (E. <@}.;._1 ]) ,) ])
S=: 'x = {} p = {} -x^p {} -(x)^p {} (-x)^p {} -(x^p) {}'
 
explicit=: dyad def 'S format~ 2 2 4 4 4 4 ":&> x,y,(-x^y),(-(x)^y),((-x)^y),(-(x^y))'
tacit=: S format~ 2 2 4 4 4 4 ":&> [`]`([:-^)`([:-^)`((^~-)~)`([:-^)`:0
 
_2 explicit/\_5 2 _5 3 5 2 5 3
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
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
-:/ 1 0 2 |: _2(tacit ,: explicit)/\_5 2 _5 3 5 2 5 3 NB. the verbs produce matching results
1
</pre>
=={{header|Julia}}==
In Julia, the ^ symbol is the power infix operator. The ^ operator has a higher precedence than the - operator,
Anonymous user