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

Put all power functions in Haskell
(Haskell added)
(Put all power functions in Haskell)
Line 257:
main = do
print [-5^2,-(5)^2,(-5)^2,-(5^2)] --Integer
print [-5^^2,-(5)^^2,(-5)^^2,-(5^^2)] --Fractional
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)] --Fractional
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]
[-25.0,-25.0,25.0,-25.0]
[-125,-125,-125,-125]
[-125.0,-125.0,-125.0,-125.0]
[-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