uiua-lang/uiua

Modifier suggestion: Assign inverse

Closed this issue · 2 comments

Potentially useful when you want to have a mathematical function and allow calling its inverse with inv F, or allow more dual operations using under F like read-write, open-close, etc. Mathematical duals also appear in graphics domain I think.

J calls this assign obverse, or just "obverse".

I could add this, although it would be limited in that it would only let you assign inverses to operations where no information is lost in the result. This would make it usable with invert and under, but the number of functions this is useful for is limited.
The problem is that a lot of underable operations inherently destroy information.
An example is first. You can't invert first because once you have the first row, the rest of the array is gone.
under first works because it actually generates a "before" function and an "after" function, neither of which is exactly the same as first itself. These generated functions use special instructions that save data to a hidden stack so that it can be used when undoing an operation. These instructions are not available to the user.

This has been added! (experimentally)
See setinv and setund