|
1 | 1 | using Combinatorics
|
2 | 2 | using Base.Test
|
3 | 3 |
|
4 |
| -@test collect(combinations([])) == [] |
5 |
| -@test collect(combinations(['a', 'b', 'c'])) == Any[['a'],['b'],['c'],['a','b'],['a','c'],['b','c'],['a','b','c']] |
| 4 | +@test [combinations([])...] == [] |
| 5 | +@test [combinations(['a', 'b', 'c'])...] == Any[['a'],['b'],['c'],['a','b'],['a','c'],['b','c'],['a','b','c']] |
6 | 6 |
|
7 |
| -@test collect(combinations("abc",3)) == Any[['a','b','c']] |
8 |
| -@test collect(combinations("abc",2)) == Any[['a','b'],['a','c'],['b','c']] |
9 |
| -@test collect(combinations("abc",1)) == Any[['a'],['b'],['c']] |
10 |
| -@test collect(combinations("abc",0)) == Any[[]] |
11 |
| -@test collect(combinations("abc",-1)) == [] |
| 7 | +@test [combinations("abc",3)...] == Any[['a','b','c']] |
| 8 | +@test [combinations("abc",2)...] == Any[['a','b'],['a','c'],['b','c']] |
| 9 | +@test [combinations("abc",1)...] == Any[['a'],['b'],['c']] |
| 10 | +@test [combinations("abc",0)...] == Any[[]] |
| 11 | +@test [combinations("abc",-1)...] == [] |
12 | 12 |
|
13 |
| -@test collect(filter(x->(iseven(x[1])),combinations([1,2,3],2))) == Any[[2,3]] |
| 13 | +@test filter(x->iseven(x[1]),[combinations([1,2,3],2)...]) == Any[[2,3]] |
14 | 14 |
|
15 | 15 | # multiset_combinations
|
16 |
| -@test collect(multiset_combinations("aabc", 5)) == Any[] |
17 |
| -@test collect(multiset_combinations("aabc", 2)) == Any[['a','a'],['a','b'],['a','c'],['b','c']] |
18 |
| -@test collect(multiset_combinations("aabc", 1)) == Any[['a'],['b'],['c']] |
19 |
| -@test collect(multiset_combinations("aabc", 0)) == Any[Char[]] |
20 |
| -@test collect(multiset_combinations("aabc", -1)) == Any[] |
21 |
| -@test collect(multiset_combinations("", 1)) == Any[] |
22 |
| -@test collect(multiset_combinations("", 0)) == Any[Char[]] |
23 |
| -@test collect(multiset_combinations("", -1)) == Any[] |
| 16 | +@test [multiset_combinations("aabc", 5)...] == Any[] |
| 17 | +@test [multiset_combinations("aabc", 2)...] == Any[['a','a'],['a','b'],['a','c'],['b','c']] |
| 18 | +@test [multiset_combinations("aabc", 1)...] == Any[['a'],['b'],['c']] |
| 19 | +@test [multiset_combinations("aabc", 0)...] == Any[Char[]] |
| 20 | +@test [multiset_combinations("aabc", -1)...] == Any[] |
| 21 | +@test [multiset_combinations("", 1)...] == Any[] |
| 22 | +@test [multiset_combinations("", 0)...] == Any[Char[]] |
| 23 | +@test [multiset_combinations("", -1)...] == Any[] |
24 | 24 |
|
25 | 25 | # with_replacement_combinations
|
26 |
| -@test collect(with_replacement_combinations("abc", 2)) == Any[['a','a'],['a','b'],['a','c'], |
| 26 | +@test [with_replacement_combinations("abc", 2)...] == Any[['a','a'],['a','b'],['a','c'], |
27 | 27 | ['b','b'],['b','c'],['c','c']]
|
28 |
| -@test collect(with_replacement_combinations("abc", 1)) == Any[['a'],['b'],['c']] |
29 |
| -@test collect(with_replacement_combinations("abc", 0)) == Any[Char[]] |
30 |
| -@test collect(with_replacement_combinations("abc", -1)) == Any[] |
31 |
| -@test collect(with_replacement_combinations("", 1)) == Any[] |
32 |
| -@test collect(with_replacement_combinations("", 0)) == Any[Char[]] |
33 |
| -@test collect(with_replacement_combinations("", -1)) == Any[] |
| 28 | +@test [with_replacement_combinations("abc", 1)...] == Any[['a'],['b'],['c']] |
| 29 | +@test [with_replacement_combinations("abc", 0)...] == Any[Char[]] |
| 30 | +@test [with_replacement_combinations("abc", -1)...] == Any[] |
| 31 | +@test [with_replacement_combinations("", 1)...] == Any[] |
| 32 | +@test [with_replacement_combinations("", 0)...] == Any[Char[]] |
| 33 | +@test [with_replacement_combinations("", -1)...] == Any[] |
34 | 34 |
|
35 | 35 |
|
36 | 36 | #cool-lex iterator
|
37 |
| -@test_throws DomainError collect(CoolLexCombinations(-1, 1)) |
38 |
| -@test_throws DomainError collect(CoolLexCombinations(5, 0)) |
39 |
| -@test collect(CoolLexCombinations(4,2)) == Vector[[1,2], [2,3], [1,3], [2,4], [3,4], [1,4]] |
| 37 | +@test_throws DomainError [CoolLexCombinations(-1, 1)...] |
| 38 | +@test_throws DomainError [CoolLexCombinations(5, 0)...] |
| 39 | +@test [CoolLexCombinations(4,2)...] == Vector[[1,2], [2,3], [1,3], [2,4], [3,4], [1,4]] |
40 | 40 | @test isa(start(CoolLexCombinations(1000, 20)), Combinatorics.CoolLexIterState{BigInt})
|
0 commit comments