-
Notifications
You must be signed in to change notification settings - Fork 32
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 prodfactors
and radical
functions
#42
Conversation
src/Primes.jl
Outdated
""" | ||
function factorback end | ||
|
||
factorback(factors::Associative) = prod(p^i for (p, i) in factors) |
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.
Julia 0.4 has array comprehensions but not Generator
s, which is causing the test failures on 0.4. I think we should just drop 0.4 support at this point. I can submit a PR for that later.
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 keep forgetting about that!
Might as well export it, IMO, or at least add it to the docs. Seems pretty cool. |
I'm not 100% sold on the name |
I actually also like |
de79027
to
130aedb
Compare
Ok, exported |
Even if we could reclaim Now, if we wanted to support only going from a We could do something like |
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.
Looks good to me, pending any renaming of factorback
.
src/Primes.jl
Outdated
""" | ||
function factorback end | ||
|
||
factorback(factors::Associative) = prod([p^i for (p, i) in factors]) |
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.
Support for 0.4 is now a thing of the past, so this can be the bare generator expression again if you'd prefer. I did a benchmark to see whether having it in an array comprehension versus a generator made a difference and it doesn't for the most part, so changing isn't really necessary, just thought I'd give you a heads up.
docs/src/api.md
Outdated
@@ -4,6 +4,7 @@ | |||
|
|||
```@docs | |||
Primes.factor | |||
Primes.factorback |
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.
Could you add radical
here too? (Or wherever the appropriate place in the docs is)
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.
Good catch.
Indeed |
a3fcabd
to
01f171c
Compare
Someone likes to feed the bikeshed here?! |
Instead of |
Hm, I'm not really a fan of shadowing Base functions like that. I do still like |
Let's forget about the shadowing (of which I'm not a big fan either), I prefer |
Ah yeah, I like |
factorback
and radical
functionsprodfactors
and radical
functions
EDIT TITLE: renamed
factorback
->prodfactors
(not updated below).Add
factorback
such thatfactorback(Container, factor(n)) == n
(cf. docstrings for details).The name ("factorback" comes from the "pari" package) can of course be bikeshed, cf. JuliaLang/LinearAlgebra.jl#229.
I like also the name
factorprod
(but there was an objection in the linked issue).I also added the function
radical
as it was natural to do so, but didn't export it (yet).