-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
[#724] New practice exercise rational-numbers
#755
[#724] New practice exercise rational-numbers
#755
Conversation
Thank you for contributing to Based on the files changed in this PR, it would be good to pay attention to the following details when reviewing the PR:
Automated comment created by PR Commenter 🤖. |
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.
Keep the PRs coming! 😂 ❤️
"basics", | ||
"integers", | ||
"floating-point-numbers", | ||
"guards" |
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.
If the solution requires :math.pow
, we have those options:
- Add prerequisite
erlang-libraries
, assuming the student will use:math.pow
- Add prerequisites that allow reimplementing
:math.pow
yourself, I'm guessing that would be eitherrecursion
orenum
withranges
? - Do nothing assuming most students will use Elixir 1.12 where
Integer.pow
andFloat.pow
are available
@neenjaw opinions? 🤔
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 think option 2 is the weakest, because Float.pow
would be too hard to implement, people would search for it and find either :math.pow
or the 1.12 functions.
I also think that not all students will have 1.12, that being said, one could understand basics
as including basic math functions, so I don't really know which option to pick either.
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.
The concern when Elixir was a lot smaller was that distro's didn't update their binaries very often. I think with Elixir's growing popularity distro , I'm personally of a stance not worrying too much about supporting legacy versions. I think options 1/3 are both reasonable. If we are looking at v3 in august, by then 1.12 will have been out for a few months making it much more reasonable to assume new comers would be using it
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.
Ok, let's go with option 3. I'm convinced by:
If we are looking at v3 in august, by then 1.12 will have been out for a few months
For the record:
one could understand basics as including basic math functions
The way we defined concepts, basics
includes using integer literals and basic math operators defined in the Kernel
module (+
, -
, *
, /
), but using the Integer
module is part of the integers
concept 🙂.
end | ||
|
||
describe "Exponentiation of a real number to a rational number" do | ||
# We round float values to 10 decimal places to allow comparaison |
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.
Let's use assert_in_delta
instead of rounding. It's the usual tool to use in unit tests for floats 🙂. I'm not certain if it makes any practical difference, but at least the code will be a bit shorter. Maybe we can put the delta value in a module attribute?
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.
Thank you, I didn't know about assert_in_delta
even though in hindsight of course it exists.
@@ -0,0 +1,59 @@ | |||
defmodule RationalNumbers do | |||
@type rational :: {integer, integer} |
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.
👍
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.
Nice work yet again!
Closes #724 |
Here I go again!