Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/combinations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ end
Generate combinations of the elements of `a` of all orders. Chaining of order iterators
is eager, but the sequence at each order is lazy.
"""
combinations(a) = Iterators.flatten([combinations(a, k) for k = 1:length(a)])


combinations(a) = Iterators.flatten([combinations(a, k) for k = 0:length(a)])

# cool-lex combinations iterator

Expand Down
5 changes: 3 additions & 2 deletions test/combinations.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@testset "combinations" begin
@test [combinations([])...] == []
@test [combinations(['a', 'b', 'c'])...] == [['a'], ['b'], ['c'], ['a', 'b'], ['a', 'c'], ['b', 'c'], ['a', 'b', 'c']]
@test [combinations([])...] == [[]]
@test [combinations(['a', 'b', 'c'])...] == [[],['a'],['b'],['c'],['a','b'],['a','c'],['b','c'],['a','b','c']]
@test length(collect(combinations(1:5))) == 32

@test [combinations("abc", 3)...] == [['a', 'b', 'c']]
@test [combinations("abc", 2)...] == [['a', 'b'], ['a', 'c'], ['b', 'c']]
Expand Down
Loading