Skip to content

Commit e498d0a

Browse files
yuyichaoararslan
authored andcommitted
Fix 0.6 depwarns (#34)
1 parent c78f3af commit e498d0a

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/Primes.jl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ module Primes
44

55
using Compat
66

7+
if isdefined(Base, :Iterators)
8+
import Base.Iterators: repeated
9+
end
10+
711
if VERSION >= v"0.5.0-dev+4340"
812
if isdefined(Base,:isprime)
913
import Base: isprime, primes, primesmask, factor
@@ -354,8 +358,14 @@ factor{T<:Any}(::Type{T}, n) = throw(MethodError(factor, (T, n)))
354358

355359
function pollardfactors!{T<:Integer,K<:Integer}(n::T, h::Associative{K,Int})
356360
while true
357-
local c::T = rand(1:(n - 1)), G::T = 1, r::K = 1, y::T = rand(0:(n - 1)), m::K = 1900
358-
local ys::T, q::T = 1, x::T
361+
c::T = rand(1:(n - 1))
362+
G::T = 1
363+
r::K = 1
364+
y::T = rand(0:(n - 1))
365+
m::K = 1900
366+
ys::T = 0
367+
q::T = 1
368+
x::T = 0
359369
while c == n - 2
360370
c = rand(1:(n - 1))
361371
end
@@ -365,7 +375,7 @@ function pollardfactors!{T<:Integer,K<:Integer}(n::T, h::Associative{K,Int})
365375
y = y^2 % n
366376
y = (y + c) % n
367377
end
368-
local k::K = 0
378+
k::K = 0
369379
G = 1
370380
while k < r && G == 1
371381
for i in 1:(m > (r - k) ? (r - k) : m)

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ for n = 1:100
185185
end
186186

187187
let i = rand(1:2^(3 * min(Sys.WORD_SIZE,64) ÷ 4))
188-
@test primes(i, i + 300) == filter(isprime, i:(i + 300)) == filter(isprime, big(i:(i + 300)))
188+
@test primes(i, i + 300) == filter(isprime, i:(i + 300)) == filter(isprime, big(i):big(i + 300))
189189
end
190190

191191

0 commit comments

Comments
 (0)