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

Haskell added
(Haskell added)
Line 253:
x = 5 e = 3 | -x.p(e) = -125 | -(x).p(e) = -125 | (-x).p(e) = -125 | -(x.p(e)) = -125
</pre>
=={{header|Haskell}}==
 
<lang Haskell>--https://wiki.haskell.org/Power_function
main = do
print [-5^2,-(5)^2,(-5)^2,-(5^2)] --Integer
print [-5**2,-(5)**2,(-5)**2,-(5**2)] --Real
print [-5^3,-(5)^3,(-5)^3,-(5^3)] --Integer
print [-5**3,-(5)**3,(-5)**3,-(5**3)] --Real</lang>
{{out}}
<pre>[-25,-25,25,-25]
[-25.0,-25.0,25.0,-25.0]
[-125,-125,-125,-125]
[-125.0,-125.0,-125.0,-125.0]</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.
678

edits