7070# ##
7171
7272"""
73- printpoly(io::IO, p::Poly, mimetype = MIME"text/plain"(); descending_powers=false, offset::Int=0)
73+ printpoly(io::IO, p::Poly, mimetype = MIME"text/plain"(); descending_powers=false, offset::Int=0, var=p.var )
7474
7575Print a human-readable representation of the polynomial `p` to `io`. The MIME
7676types "text/plain" (default), "text/latex", and "text/html" are supported. By
7777default, the terms are in order of ascending powers, matching the order in
7878`coeffs(p)`; specifying `descending_powers=true` reverses the order.
7979`offset` allows for an integer number to be added to the exponent, just for printing.
80+ `var` allows for overriding the variable used for printing.
8081
8182# Examples
8283```jldoctest
@@ -88,13 +89,15 @@ julia> printpoly(stdout, Poly([2, 3, 1], :z), descending_powers=true, offset=-2)
88891 + 3*z^-1 + 2*z^-2
8990julia> printpoly(stdout, Poly([-1, 0, 1], :z), offset=-1, descending_powers=true)
9091z - z^-1
92+ julia> printpoly(stdout, Poly([-1, 0, 1], :z), offset=-1, descending_powers=true, var=:x)
93+ x - x^-1
9194```
9295"""
93- function printpoly (io:: IO , p:: Poly{T} , mimetype= MIME " text/plain" (); descending_powers= false , offset:: Int = 0 ) where {T}
96+ function printpoly (io:: IO , p:: Poly{T} , mimetype= MIME " text/plain" (); descending_powers= false , offset:: Int = 0 , var = p . var ) where {T}
9497 first = true
9598 printed_anything = false
9699 for i in (descending_powers ? reverse (eachindex (p)) : eachindex (p))
97- printed = showterm (io, p[i], p . var, i+ offset, first, mimetype)
100+ printed = showterm (io, p[i], var, i+ offset, first, mimetype)
98101 first &= ! printed
99102 printed_anything |= printed
100103 end
0 commit comments