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

Special syntax for increase_by/decrease_by percentage-calculation functions #617

Open
andylima opened this issue Oct 11, 2024 · 3 comments

Comments

@andylima
Copy link

Now that the increase_by / decrease_by percentage-calculation functions have been added, it would be great to have an easy and quick syntax to do those kinds of calculations. The following syntax was proposed in the discussion of #494:
1000 -% 20
1000 +% 20

Seeing as syntax like 72 € - 15% can't be supported, the proposed syntax (above) is the next best thing, and has the advantage of being quick to type and easier to remember.

So, instead of 72 € - 15%, we would use: 72 € -% 15

@Bzero
Copy link
Contributor

Bzero commented Oct 12, 2024

Maybe I'm being unnecessarily picky but I think it is not ideal that the proposed operator dictates the unit of the second operand, in my opinion the new "increase-by" and "decrease-by" operators should work for any scalar second operand.

So 1000 <decrease-by> 20%, 1000 <decrease-by> 0.2, 1000 <decrease-by> 200‰ should all result in 800.

@Goju-Ryu
Copy link
Contributor

So 1000 <decrease-by> 20%, 1000 <decrease-by> 0.2, 1000 <decrease-by> 200‰ should all result in 800.

I think the operator notation is fine but I agree it should work the way you describe here.

@Goju-Ryu
Copy link
Contributor

Would syntax for percent_change maybe be useful too? I’m thinking something like >% and <% to denote the order of arguments. This way the problem: "how many percent increase is 50 kg to 75 kg?"
Could be written as:

50 kg >% 75 kg

I’m not quite sure if the greater than less than characters are ideal, but I think the concept might be useful.

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

3 participants