File tree Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -675,11 +675,9 @@ struct NextPrimes{T<:Integer}
675
675
start:: T
676
676
end
677
677
678
- function iterate (np:: NextPrimes ,
679
- state = p = np. start < 2 ? np. start : add (np. start, - 1 )
680
- )
681
- p = nextprime (add (state, 1 ))
682
- (p, p)
678
+ function iterate (np:: NextPrimes , state= np. start)
679
+ p = nextprime (state)
680
+ (p, add (p, 1 ))
683
681
end
684
682
685
683
IteratorSize (:: Type{<:NextPrimes} ) = Base. IsInfinite ()
@@ -725,17 +723,13 @@ struct PrevPrimes{T<:Integer}
725
723
start:: T
726
724
end
727
725
728
- function iterate (np:: PrevPrimes ,
729
- state = np. start+ one (np. start) # allow wrap-around
730
- )
731
- c = state- one (state)
732
- if isone (c)
726
+ iterate (np:: PrevPrimes , state= np. start) =
727
+ if isone (state)
733
728
nothing
734
729
else
735
- p = prevprime (c )
736
- (p, p)
730
+ p = prevprime (state )
731
+ (p, p- one (p) )
737
732
end
738
- end
739
733
740
734
IteratorSize (:: Type{<:PrevPrimes} ) = Base. SizeUnknown ()
741
735
Iteratoreltype (:: Type{<:PrevPrimes} ) = Base. HasEltype ()
You can’t perform that action at this time.
0 commit comments