Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right side operators #17

Open
srush opened this issue May 11, 2022 · 1 comment
Open

Right side operators #17

srush opened this issue May 11, 2022 · 1 comment

Comments

@srush
Copy link
Collaborator

srush commented May 11, 2022

One thing I have been needing a lot is right-headed version of composition. I am not sure of the language for this in terms of monoids, but I want it to be like :

d1 / d2 where the origin stays at d2 instead of moving to d1.

I was thinking of notating this like

d1 // d2 , but maybe that is confusing. I guess the alternative would be to have a left facing below operator d2 \ d1 if that is possible in python.

Any thoughts.

@danoneata
Copy link
Collaborator

danoneata commented May 11, 2022

Thinking out loud. I would have liked \, but I don't think it's useable (here is the list of available operators in Python). On the other hand,floordiv (//) seems like a good option: it has the advantage of having an obvious mnemonic (/ keeps the origin of the first argument; // keeps the origin of the second argument). Maybe I would have liked it to be a single character (to facilitate aligning the code and make it easier on the eye), but this is a lesser aspect.

I assume we want a similar pair of operators for horizontal composition as well. So, if at all possible, it would be nice to achieve some consistency across the two types of compositions (vertical v and horizontal h). With this in mind, here are some options:

   origin at
   1 2
h: * **
v: / //

or maybe something like this:

   origin at
   1 2
h: & |
v: / %

(I usually associate & with first and | with second, maybe due to the short-circuit evaluation of the booleans. Although, after looking at this second option, I feel there are too many symbols to remember...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants