# Operator which can be interpreted as binary and unary

I'm a bit lost with the way how e.g. the + operator is implemented in Mathematica as binary (infix) and unary (prefix) operator depending on the context, since I would like to define a similiar behaviour e.g. for the CirclePlus operator.

If one uses the $+$ operator as $+a$ then one gets the expected result $a$.

Since $+$ is by definition a Binary operator the expression $a+b$ is translated into $Plus[a,b]$.

Now how could I specify a similar behavior for e.g the $\oplus$ binary operator? Obviously $a \oplus b$ is translating nicely into CirclePlus[a,b] as expected.

However if I try $\oplus a$ I get a syntax error "$\oplus a$ is incomplete; more input is needed."

I'm sure I miss here some additional definition or rule necessary to get this behavior.

• There could be something of use in the Notation package. I've never defined a unary operator, only binary infix, but this looks helpful – Histograms May 16 '15 at 16:37
• Plus has the OneIdentity attribute, that's why Plus[a] = a. Try setting that attribute for CirclePlus. Or more generally, just define what CirclePlus[a] should be, as it doesn't have any built-in meaning. – Marius Ladegård Meyer May 16 '15 at 17:03
• @MariusLadegårdMeyer: Both approaches are unfortunately not working. The error still persists. – Rainer May 16 '15 at 18:25
• Rainer, are you sure of that? Because if I set CirclePlus[x_]=x on my machine, then evaluate CirclePlus[a], I obtain a as the output, which I thought is what you want. – MarcoB May 16 '15 at 21:09
• Try this: MakeExpression[RowBox[{"[CirclePlus]", x_}], StandardForm] := MakeExpression[RowBox[{x}], StandardForm] – jamtype7 May 16 '15 at 21:13