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

Add max and min math functions #7856

Closed
IlanCosman opened this issue Mar 23, 2021 · 2 comments
Closed

Add max and min math functions #7856

IlanCosman opened this issue Mar 23, 2021 · 2 comments

Comments

@IlanCosman
Copy link
Contributor

IlanCosman commented Mar 23, 2021

It's not super common, but I've found myself wanting these functions to set upper and lower bounds on things.

Obviously this is just a nice tool to have, but as a specific use case, some string commands like pad and repeat will error if you give them negative numbers. Obviously we can't use abs here, so I've been doing test $blah -lt 0 && set $blah 0. This works of course, but it is less elegant and requires setting the value to a variable first.

@ridiculousfish
Copy link
Member

Seems reasonable, tinyexpr isn't really set up for functions of arbitrary arity, so it's a bit of a dive, but still a fun isolated change. Start with tinyexpr functions.

@IlanCosman
Copy link
Contributor Author

This has been implemented. If anyone wants to mark this Fish 3.3, that'd be cool 😄

@faho faho modified the milestones: fish-future, fish 3.3.0 Mar 29, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants