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 LeastCommonMultiple and GreatestCommonDivisor to math package #4001

Merged
merged 12 commits into from
Feb 16, 2022

Conversation

SeanTAllen
Copy link
Member

@SeanTAllen SeanTAllen commented Feb 8, 2022

Adds code for determining least common multiple and greatest common divisor to the standard library math package.

@SeanTAllen SeanTAllen requested a review from a team February 8, 2022 13:48
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Feb 8, 2022
@SeanTAllen SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Feb 8, 2022
@SeanTAllen
Copy link
Member Author

@ponylang/committer this is ready for another review. I've address @jemc's comments.

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Feb 8, 2022
@SeanTAllen
Copy link
Member Author

@EpicEric are you good with this now?

Copy link
Contributor

@EpicEric EpicEric left a comment

Choose a reason for hiding this comment

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

I'd expect some tests for the new functionality. Other than that, I left a minor style suggestion.

@SeanTAllen
Copy link
Member Author

SeanTAllen commented Feb 10, 2022

What do you expect as tests? I don't see much value in a couple of unit tests. I could see some value in property tests if ponycheck becomes part of the standard library.

If you have an idea for tests, please feel free to add.

@EpicEric
Copy link
Contributor

I'd also prefer property tests, but since these aren't in the stdlib yet, I personally feel that simple tests are better than no tests.

Some simple tests could be:

  1. Prime arguments (GCD is 1, LCM is the product)
t.assert_eq[U32](GreatestCommonDivisor[U32](373, 1231)?, U32(1))
t.assert_eq[U32](LeastCommonMultiple[U32](373, 1231)?, U32(373) * U32(1231))
  1. Equal arguments (GCD and LCM should both be equal to the argument)
t.assert_eq[U32](GreatestCommonDivisor[U32](0x506F6E79, 0x506F6E79)?, U32(0x506F6E79))
t.assert_eq[U32](LeastCommonMultiple[U32](0x506F6E79, 0x506F6E79)?, U32(0x506F6E79))

@SeanTAllen
Copy link
Member Author

@EpicEric tests added

@SeanTAllen SeanTAllen added the changelog - added Automatically add "Added" CHANGELOG entry on merge label Feb 15, 2022
@SeanTAllen SeanTAllen changed the title Add LCM and GCD to math package Add LeastCommonMultiple and GreatestCommonDivisor to math package Feb 15, 2022
@SeanTAllen SeanTAllen merged commit 16861a5 into main Feb 16, 2022
@SeanTAllen SeanTAllen deleted the lcm-gcd branch February 16, 2022 04:07
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Feb 16, 2022
github-actions bot pushed a commit that referenced this pull request Feb 16, 2022
github-actions bot pushed a commit that referenced this pull request Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - added Automatically add "Added" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants