Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
combinations returns a list of arrays these days
  • Loading branch information
TimToady committed Aug 2, 2014
1 parent 26d1dda commit db80199
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions S32-list/combinations.t
Expand Up @@ -2,16 +2,12 @@ use Test;

plan 6;

sub canon($t) {
$t.tree.map(*.sort).tree
}

# L<S32::Containers/List/=item combinations>

ok(((1,), (2,), (3,)).list eqv [1, 2, 3].combinations(1).&canon, "single-item combinations");
ok(all([1, 2], [2, 3], [1, 3]) eqv one([1, 2, 3].combinations(2).&canon), "two item combinations");
ok(([1, 2, 3],).list eqv [1, 2, 3].combinations(3).&canon, "three items of a three-item list");
ok [1, 2, 3].combinations(1) »eqv« ([1], [2], [3]), "single-item combinations";
ok [1, 2, 3].combinations(2) »eqv« ([1, 2], [2, 3], [1, 3]), "two item combinations";
ok [1, 2, 3].combinations(3) »eqv« ([1,2,3],), "three items of a three-item list";

ok(all(1, 2, 3, [1, 2], [2, 3], [1, 3]) eqv one([1, 2, 3].combinations(1..2).&canon), "1..2 items");
ok(all(1, 2, 3, [1, 2], [2, 3], [1, 3], [1, 2, 3]) eqv one([1, 2, 3].combinations(1..3).&canon), "1..3 items");
ok(all([1, 2], [2, 3], [1, 3], [1, 2, 3]) eqv one([1, 2, 3].combinations(2..3).&canon), "2..3 items");
ok [1, 2, 3].combinations(1..2) »eqv« ([1], [2], [3], [1, 2], [2, 3], [1, 3]), "1..2 items";
ok [1, 2, 3].combinations(1..3) »eqv« ([1], [2], [3], [1, 2], [2, 3], [1, 3], [1, 2, 3]), "1..3 items";
ok [1, 2, 3].combinations(2..3) »eqv« ([1, 2], [2, 3], [1, 3], [1, 2, 3]), "2..3 items";

0 comments on commit db80199

Please sign in to comment.