-
Notifications
You must be signed in to change notification settings - Fork 581
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 clamp function #545
Add clamp function #545
Conversation
|
This would also need a readme update. Thanks for the work. |
|
Done |
|
Thanks for the quick response 👍 So reading your implementations of clamp i would prefer the parameter ordering of: value, min, max I think the function should be limited to 3 values, and not allowing arrays. |
|
Actually the order of params doesn't matter, it could be [max, min, value] or [max, value, min] or ... whatever. |
|
In other words you might have $range = [minLimit, maxLimit] and valueX. |
|
Bump |
| else | ||
| result << x | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't this just be args = args.flatten ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, thanx
|
Hi Michael, I added a few comments on issues with the code. I think the overall idea of the clamp function is great, but the code does need a bit work. Especially with the move of puppet 4 to more conscious and strict typing, please reconsider your plan to allow arbitrary arrays and strings as arguments. I would much prefer a more strict signature like tp suggested, that does just take three ints. |
Clamp keeps value within the range. Employ of soft() makes the whole thing is independant of order.
|
Hi David, thank you for the feedback. I've fixed issues w/ the code. |
|
Thanks for your work, @mpolenchuk ! |
Clamp keeps value within the range.
Employ of soft() makes the whole thing is independant of order.