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

Added Summation&Product #4

Merged
merged 2 commits into from Mar 14, 2022
Merged

Added Summation&Product #4

merged 2 commits into from Mar 14, 2022

Conversation

Gentil-N
Copy link
Contributor

I have added two common operations : summation and product.

Even if we can use iterators, it seems that Python sum doesn't have any equivalent in Rust.

@At0micBee
Copy link
Owner

This is a good idea too, I've just been trying it out and for the most part it seems to work, I have however notice some improvements that could be done easily, to name a few:

  1. If the stop value is smaller than the start value, the operations do not work
  2. The operations do not work for floats; which isn't necessarily a problem, but ensuring it does work for them could be a good thing
  3. Maybe move the macros to the range.rs module, which feels more appropriate for it

Thanks again!

@Gentil-N
Copy link
Contributor Author

Yeah, so:

  1. Instead of a couple "start&stop", I set a range expression: summation!(u32, n, 0..=10, n). Because, to process all possible types of range (where stop is smaller than start for instance) could be too heavy. With this method, the problem is redirected to users and we use the standard range.
  2. I am not sure what you mean: if you talk about the formula into the operations, the following summation!(f64, n, 0..=10, n as f64 * 0.5) is working.
  3. Ok, done!

You're welcome!

@At0micBee
Copy link
Owner

  1. Great, that'll do!
  2. Yeah you're right, I forgot I could do that...
  3. Perfect.

Merging now.

@At0micBee At0micBee merged commit ce0aea0 into At0micBee:master Mar 14, 2022
@Gentil-N Gentil-N deleted the sumprod branch March 16, 2022 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants