]> granicus.if.org Git - python/commitdiff
Clarify the table entries for combinatorics.
authorRaymond Hettinger <python@rcn.com>
Fri, 10 Apr 2009 04:25:45 +0000 (04:25 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 10 Apr 2009 04:25:45 +0000 (04:25 +0000)
Doc/library/itertools.rst

index 0b7907295d6f1f76c9d4f8e5b6ef8027da7b2982..85baaa34a674677a18c22fcd2f6a123090e57865 100644 (file)
@@ -66,14 +66,19 @@ operator can be mapped across two vectors to form an efficient dot-product:
 
 **Combinatoric generators:**
 
-    =====================================   ====================       =================================================
-    Iterator                                Arguments                  Results
-    =====================================   ====================       =================================================
-    :func:`product`                         p, q, ... [repeat=1]       cartesian product
-    :func:`permutations`                    p[, r]                     r-length permutations (without repeated elements)
-    :func:`combinations`                    p[, r]                     r-length combinations (sorted and no repeats)
-    :func:`combinations_with_replacement`   p[, r]                     r-length combinations (sorted but with repeats)
-    =====================================   ====================       =================================================
+    ==============================================   ====================       =============================================================
+    Iterator                                         Arguments                  Results
+    ==============================================   ====================       =============================================================
+    :func:`product`                                  p, q, ... [repeat=1]       cartesian product, equivalent to a nested for-loop
+    :func:`permutations`                             p[, r]                     r-length tuples, all possible orderings, no repeated elements
+    :func:`combinations`                             p[, r]                     r-length tuples, in sorted order, no repeated elements
+    :func:`combinations_with_replacement`            p[, r]                     r-length tuples, in sorted order, with repeated elements
+    |
+    ``product('ABCD', repeat=2)``                                               ``AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD``
+    ``permutations('ABCD', 2)``                                                 ``AB AC AD BA BC BD CA CB CD DA DB DC``
+    ``combinations('ABCD', 2)``                                                 ``AB AC AD BC BD CD``
+    ``combinations_with_replacement('ABCD', 2)``                                ``AA AB AC AD BB BC BD CC CD DD``
+    ==============================================   ====================       =============================================================
 
 
 .. _itertools-functions: