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

[Feature Request] Add a convenience macro for making Polynomials #499

Open
AwesomeQuest opened this issue May 9, 2023 · 2 comments
Open

Comments

@AwesomeQuest
Copy link

It would be nice if there where a convenient way to make a Polynomial without having to write out every time "Polynomial"

For instance, including something like:

macro P_str(s)
    Polynomial(eval(Meta.parse("["*s*"]")))
end

Makes it easy to make a Polynomial like so:

julia> P"1,2,4,5,6"
Polynomial(1 + 2*x + 4*x^2 + 5*x^3 + 6*x^4)
@jverzani
Copy link
Member

jverzani commented May 9, 2023

Hmm, we recently added a macro @variable to make a variable easier to type. Maybe adding an @poly 1 2 3 4 5 would be helpful. I have to see if there are other uses in the many other Polynomial packages so as not to be too conflicting.

@jverzani
Copy link
Member

This might be best left to an example, the code can be as simple as:

 macro poly(as...)
     Polynomial(as)
end

Would you like to add this to the documentation somewhere?

(Though the above exposes an issue with promotion when arguments are passed as a tuple.)

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

No branches or pull requests

2 participants