We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 909ea47 + 55fd848 commit 227b3acCopy full SHA for 227b3ac
src/Polynomials.jl
@@ -12,7 +12,7 @@ export degree, coeffs, variable
12
export polyval, polyint, polyder, roots, polyfit
13
export Pade, padeval
14
15
-import Base: start, next, done, length, size, eltype, collect
+import Base: start, next, done, length, size, eltype, collect, eachindex
16
import Base: endof, getindex, setindex!, copy, zero, one, convert, norm, gcd
17
import Base: show, print, *, /, //, -, +, ==, isapprox, divrem, div, rem, eltype
18
import Base: promote_rule, truncate, chop, conj, transpose, dot, hash
@@ -286,7 +286,7 @@ end
286
287
setindex!(p::Poly, values, ::Colon) = setindex!(p, values, 0:length(p)-1)
288
289
-eachindex{T}(p::Poly{T}) = 0:(length(p)-1)
+eachindex(p::Poly) = 0:degree(p)
290
291
copy(p::Poly) = Poly(copy(p.a), p.var)
292
test/runtests.jl
@@ -339,3 +339,5 @@ end
339
@test_throws InexactError collect(Poly{Int}, Poly([1.2]))
340
341
@test length(collect(p1)) == degree(p1)+1
342
+
343
+@test [p1[idx] for idx in eachindex(p1)] == [1,2,0,3]
0 commit comments