Skip to content

Commit

Permalink
Merge pull request #97 from nsajko/immutable
Browse files Browse the repository at this point in the history
make BinomialIterState immutable
  • Loading branch information
oxinabox authored Dec 18, 2023
2 parents 0791c83 + c5ef5eb commit 8f22a00
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/IterTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ IteratorEltype(::Type{Binomial{C}}) where {C} = IteratorEltype(C)

subsets(xs, k) = Binomial(xs, length(xs), k)

mutable struct BinomialIterState
struct BinomialIterState
idx::Vector{Int64}
done::Bool
end
Expand All @@ -573,9 +573,7 @@ function iterate(it::Binomial, state=BinomialIterState(collect(Int64, 1:it.k), i
end
end

state.done = i == 0

return set, state
return set, BinomialIterState(idx, i == 0)
end


Expand Down

0 comments on commit 8f22a00

Please sign in to comment.