File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 531
531
532
532
# add: checked add (when makes sense), result of same type as first argument
533
533
534
- add (n:: BigInt , x:: Int ) = n+ x
534
+ add (n:: BigInt , x:: Int ) = n + x
535
535
add (n:: Integer , x:: Int ) = Base. checked_add (n, oftype (n, x))
536
536
537
537
# add_! : "may" mutate the Integer argument (only for BigInt currently)
@@ -723,13 +723,14 @@ struct PrevPrimes{T<:Integer}
723
723
start:: T
724
724
end
725
725
726
- iterate (np:: PrevPrimes , state= np. start) =
726
+ function iterate (np:: PrevPrimes , state= np. start)
727
727
if isone (state)
728
728
nothing
729
729
else
730
730
p = prevprime (state)
731
731
(p, p- one (p))
732
732
end
733
+ end
733
734
734
735
IteratorSize (:: Type{<:PrevPrimes} ) = Base. SizeUnknown ()
735
736
IteratorEltype (:: Type{<:PrevPrimes} ) = Base. HasEltype ()
Original file line number Diff line number Diff line change 407
407
@test nextprimes (4 , 1 )[1 ] == nextprimes (5 , 1 )[1 ] == 5
408
408
@test eltype (nextprimes (10 )) == Int
409
409
@test eltype (nextprimes (big (10 ))) == BigInt
410
+ @test Base. IteratorEltype (nextprimes (10 )) == Base. HasEltype ()
411
+ @test Base. IteratorSize (nextprimes (10 )) == Base. IsInfinite ()
412
+
410
413
end
411
414
412
415
419
422
@test prevprimes (6 , 1 )[1 ] == prevprimes (5 , 1 )[1 ] == 5
420
423
@test prevprimes (4 , 1 )[1 ] == prevprimes (3 , 1 )[1 ] == 3
421
424
@test prevprimes (2 , 1 )[1 ] == 2
425
+ @test isempty (prevprimes (1 , 1 ))
422
426
let p8 = collect (prevprimes (typemax (Int8)))
423
427
@test length (p8) == 31
424
428
@test p8[end ] == 2
427
431
end
428
432
@test eltype (prevprimes (10 )) == Int
429
433
@test eltype (prevprimes (big (10 ))) == BigInt
434
+ @test Base. IteratorEltype (prevprimes (10 )) == Base. HasEltype ()
435
+ @test Base. IteratorSize (prevprimes (10 )) == Base. SizeUnknown ()
430
436
end
You can’t perform that action at this time.
0 commit comments