Open
Description
Currently
julia> partitions(0)|>collect
1-element Array{Any,1}:
#undef
This is unexpected because the partition of the empty set is the empty set so I would expect
patitions(0)|>collect == [[]]
This results in unexpected behviour here:
julia> [length(b) for b in partitions(1)]
1-element Array{Int64,1}:
1
julia> [length(b) for b in partitions(0)]
1-element Array{Int64,1}:
4492284592
# I expect this
julia> [length(b) for b in [[]]]
1-element Array{Int64,1}:
0
Metadata
Metadata
Assignees
Labels
No labels
Activity
jessebett commentedon Jul 11, 2019
I don’t know enough about defining Iterators to solve this 😞
I believe that the bug is
since
length(xs)==0
this returns nothing. I don't know how to have iterate here return[[]]
only once.mschauer commentedon Jul 11, 2019
This does the trick, needs some test etc.
Ah, no, this returns
[0]
which is not wrong but not "normalized"simonschoelly commentedon Jul 12, 2019
Then maybe add this as a second function:
and change the signature of the other function from
function Base.iterate(p::IntegerPartitions, xs = Int[])
tofunction Base.iterate(p::IntegerPartitions, xs)
.