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

chore(docs): Add examples to Number module #2015

Merged
merged 3 commits into from Mar 4, 2024

Conversation

spotandjake
Copy link
Member

This pr improves the documentation on the Number module, by adding examples to most functions. It also adds a missing since property to Number.sign.

Notes:

  • I omitted examples on the functions that take a Range until we have proper syntax.
  • Our trig functions are currently not precise enough for good examples, I think we might need to look into rewriting them Stdlib: Reintroduce sin, cos, tan, gamma, factorial functions #1478 had been an issue to make Number.sin unbounded, but I noticed during this pr that was not the actual problem, the problem is how we map the input range and also with our implementation.

@spotandjake spotandjake added stdlib documentation Issues related to documentation. labels Feb 13, 2024
@spotandjake spotandjake self-assigned this Feb 13, 2024
stdlib/number.gr Outdated Show resolved Hide resolved
@ospencer
Copy link
Member

Let's make sure something akin to #2032 is merged before we land this.

Copy link
Member

@phated phated left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs conflicts resolved since we removed some trig functions

@phated
Copy link
Member

phated commented Mar 1, 2024

@spotandjake more conflicts (due to atan2?)

Copy link
Member

@phated phated left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but getting @ospencer or @alex-snezhko review

@phated phated changed the title chore(stdlib): Improve Number docs chore(docs): Add examples to Number module Mar 3, 2024
@@ -337,6 +409,13 @@ provide let isInteger = (x: Number) => {
* @param x: The number to check
* @returns `true` if the value is a non-integer rational number or `false` otherwise
*
* @example Number.isRational(1/2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No == true here?

Comment on lines +433 to +436
* @example Number.isFinite(1/2)
* @example Number.isFinite(0.5)
* @example Number.isFinite(1.0)
* @example Number.isFinite(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And these?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is this our style? Just feels a little weird since it's not an assertion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't been paying that close of attention. I know jake was doing assert in some cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have been using assert semantics for single line matches throughout the stdlib.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spotandjake why don't these contain assert then?

@phated phated added this pull request to the merge queue Mar 4, 2024
Merged via the queue into grain-lang:main with commit 0eca462 Mar 4, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues related to documentation. stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants