-
-
Notifications
You must be signed in to change notification settings - Fork 310
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
Adds a Num.restrictToInterval function #6286
base: main
Are you sure you want to change the base?
Conversation
We don't run expects tests for Num.roc yet. I need to do #6289 before we merge this. |
This reverts commit 09f7bdd.
## restrictToInterval 10 { startAt: 3, endAt: 8 } == 8 | ||
|
||
## restrictToInterval 5 { startAt: 8, endAt: 3 } == 5 |
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.
## restrictToInterval 10 { startAt: 3, endAt: 8 } == 8 | |
## restrictToInterval 5 { startAt: 8, endAt: 3 } == 5 | |
## restrictToInterval 10 { startAt: 3, endAt: 8 } == 8 | |
## | |
## restrictToInterval 5 { startAt: 8, endAt: 3 } == 5 |
## restrictToInterval 1 { startAt: 8, endAt: 3 } == 3 | ||
## restrictToInterval 10 { startAt: 8, endAt: 3 } == 8 | ||
## ``` | ||
## You may know this function as `clamp` in other languages. |
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.
I'd remove this from the Roc documentation. On the docs website, there is a way to list functions with other names in other languages:
roc/www/public/different-names/index.html
Line 19 in 26630ee
<h1>Different Names</h1> |
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.
Oh, I see you've already done the later.
if endAt > startAt then | ||
restrictToInterval x { startAt: endAt, endAt: startAt } |
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.
This doesn't seem right to me. Did you mean endAt < startAt
?
Separately, I wonder if that's the desired behavior. Maybe we should just clamp to the startAt
value in this case?
let Num.306 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; | ||
ret Num.306; |
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.
@folkertdev I wonder if there's a way we can figure out to avoid these diffs everytime a builtin changes. I don't have any good ideas, but maybe something to keep in the back of our minds.
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.
richard's ideas for making module depend solely on their contents for caching reasons should do that I think? or at least we can try to make that work in that context.
Thank you for your contribution! Sometimes PRs end up staying open for a long time without activity, which can make the list of open PRs get long and time-consuming to review. To keep things manageable for reviewers, this bot automatically closes PRs that haven’t had activity in 60 days. This PR hasn’t had activity in 30 days, so it will be automatically closed if there is no more activity in the next 30 days. Keep in mind that PRs marked |
This PR is the result from this issue and this zulip thread.