Is there a way how I can replace

inv(x)

by

x⁻¹

or

(x)⁻¹

instead? I would like to define a new postfix operator!

Is there a way how I can replace

inv(x)

by

x⁻¹

or

(x)⁻¹

instead? I would like to define a new postfix operator!

I think there is a way, but I’m not sure it’s really feasible.

One example of what you describe is the `adjoint`

function and the `'`

postfix operator

https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#Base.adjoint

Based on this post, the infix/postfix/… operators are detected in the parser. Looks like `trans-op`

/`ctrans-op`

refers to the adjoint mentioned above.

So, in principle, one could add more individual rules to parse the code and recognize postfix operators, but since `x⁻¹`

is otherwise just a normal variable name, I don’t think there is a way without hacking the parser…

I stand corrected, seems like you found the solution (I’ll link it here just for future reference):

A pretty neat example of what weird but cool things are possible

1 Like