uiua-lang / uiua

A stack-based array programming language
https://www.uiua.org
MIT License
1.51k stars 106 forks source link

Suggestion: invertible reshape #481

Open bkDJ opened 4 months ago

bkDJ commented 4 months ago

Would it make sense for °↯ to behave like △.? It seems like it would be in line with °√ already behaving like ×..

(By the way, I'm loving the work on making more of the language invertible. Sometimes if I'm writing a function that needs to go both ways, like before/after serialization, more and more is automatically invertible so only one or two bits need to be wrapped in a setinv. This suggestion stems from trying to remove as many setinvs as I can from my code)

kaikalii commented 4 months ago

Perhaps. I wonder if △. or ⊃△♭ would be more useful.

bkDJ commented 4 months ago

Good question. You know best which would make more sense. My main motivation was just to be able to write something like F ← Foo △. with the expectation that °F will "just work" if Foo is invertible too. But ⊃△♭ might indeed be the more general inversion, so I'd vote for that.