From dc271bc9557412e7bb6037ddd28e7f0f1c46772f Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 7 Dec 2010 13:03:01 -0500 Subject: [PATCH] Remove unused cruft from combinations.py --- combinations.py | 54 ------------------------------------------------- 1 file changed, 54 deletions(-) diff --git a/combinations.py b/combinations.py index 987d6db..50b7bab 100644 --- a/combinations.py +++ b/combinations.py @@ -4,24 +4,6 @@ from __future__ import generators -def xcombinations(items, n): - """Iterate through ordered, length `n` subsets of `items`. - - >>> for c in xcombinations([1, 2, 3], 2): - ... print c - [1, 2] - [1, 3] - [2, 1] - [2, 3] - [3, 1] - [3, 2] - """ - if n==0: yield [] - else: - for i in xrange(len(items)): - for cc in xcombinations(items[:i]+items[i+1:],n-1): - yield [items[i]]+cc - def xunique_combinations(items, n): """Iterate through unordered, length `n` subsets of `items`. @@ -36,39 +18,3 @@ def xunique_combinations(items, n): for i in xrange(len(items)): for cc in xunique_combinations(items[i+1:],n-1): yield [items[i]]+cc - -def xselections(items, n): - """Iterate through all length `n` multisets of `items`. - - >>> for c in xselections([1, 2, 3], 2): - ... print c - [1, 1] - [1, 2] - [1, 3] - [2, 1] - [2, 2] - [2, 3] - [3, 1] - [3, 2] - [3, 3] - """ - if n==0: yield [] - else: - for i in xrange(len(items)): - for ss in xselections(items, n-1): - yield [items[i]]+ss - -def xpermutations(items): - """Iterate through all permutations of `items`. - - >>> for c in xpermutations([1, 2, 3]): - ... print c - [1, 2, 3] - [1, 3, 2] - [2, 1, 3] - [2, 3, 1] - [3, 1, 2] - [3, 2, 1] - """ - return xcombinations(items, len(items)) - -- 2.26.2