diff --git a/src/Groups/GAPGroups.jl b/src/Groups/GAPGroups.jl index 60936f65ee4e..b7a27376d621 100644 --- a/src/Groups/GAPGroups.jl +++ b/src/Groups/GAPGroups.jl @@ -367,16 +367,10 @@ comm(x::GAPGroupElem, y::GAPGroupElem) = x^-1*x^y Base.IteratorSize(::Type{<:GAPGroup}) = Base.SizeUnknown() Base.IteratorSize(::Type{PermGroup}) = Base.HasLength() -function Base.iterate(G::GAPGroup) - L = GAPWrap.Iterator(G.X)::GapObj - i = GAPWrap.NextIterator(L)::GapObj - return group_element(G, i), L -end +Base.iterate(G::GAPGroup) = iterate(G, GAPWrap.Iterator(G.X)) function Base.iterate(G::GAPGroup, state) - if GAPWrap.IsDoneIterator(state) - return nothing - end + GAPWrap.IsDoneIterator(state) && return nothing i = GAPWrap.NextIterator(state)::GapObj return group_element(G, i), state end @@ -680,9 +674,7 @@ Base.IteratorSize(::Type{<:GAPGroupConjClass}) = Base.SizeUnknown() Base.iterate(cc::GAPGroupConjClass) = iterate(cc, GAPWrap.Iterator(cc.CC)) function Base.iterate(cc::GAPGroupConjClass{S,T}, state::GapObj) where {S,T} - if GAPWrap.IsDoneIterator(state) - return nothing - end + GAPWrap.IsDoneIterator(state) && return nothing i = GAPWrap.NextIterator(state)::GapObj if T <: GAPGroupElem return group_element(cc.X, i), state diff --git a/src/Groups/cosets.jl b/src/Groups/cosets.jl index 90f6bb5f1fe6..bee4731cfc9f 100644 --- a/src/Groups/cosets.jl +++ b/src/Groups/cosets.jl @@ -436,9 +436,7 @@ Base.IteratorSize(::Type{<:GroupCoset}) = Base.SizeUnknown() Base.iterate(G::GroupCoset) = iterate(G, GAPWrap.Iterator(G.X)) function Base.iterate(G::GroupCoset, state) - if GAPWrap.IsDoneIterator(state) - return nothing - end + GAPWrap.IsDoneIterator(state) && return nothing i = GAPWrap.NextIterator(state)::GapObj return group_element(G.G, i), state end @@ -614,9 +612,7 @@ Base.IteratorSize(::Type{<:GroupDoubleCoset}) = Base.SizeUnknown() Base.iterate(G::GroupDoubleCoset) = iterate(G, GAPWrap.Iterator(G.X)) function Base.iterate(G::GroupDoubleCoset, state) - if GAPWrap.IsDoneIterator(state) - return nothing - end + GAPWrap.IsDoneIterator(state) && return nothing i = GAPWrap.NextIterator(state)::GapObj return group_element(G.G, i), state end diff --git a/src/Groups/matrices/MatGrp.jl b/src/Groups/matrices/MatGrp.jl index 538dcacf0af2..e6348c1f1ae0 100644 --- a/src/Groups/matrices/MatGrp.jl +++ b/src/Groups/matrices/MatGrp.jl @@ -242,17 +242,10 @@ end Base.IteratorSize(::Type{<:MatrixGroup}) = Base.SizeUnknown() -function Base.iterate(G::MatrixGroup) - L=GAPWrap.Iterator(G.X)::GapObj - @assert ! GAPWrap.IsDoneIterator(L) - i = GAPWrap.NextIterator(L)::GapObj - return MatrixGroupElem(G, i), L -end +Base.iterate(G::MatrixGroup) = iterate(G, GAPWrap.Iterator(G.X)) function Base.iterate(G::MatrixGroup, state::GapObj) - if GAPWrap.IsDoneIterator(state) - return nothing - end + GAPWrap.IsDoneIterator(state) && return nothing i = GAPWrap.NextIterator(state)::GapObj return MatrixGroupElem(G, i), state end