Skip to content

Commit 151828d

Browse files
[3.13] Minor doc edit: Make multinomial() the first math example (gh-132697) (gh-132698)
1 parent a37d719 commit 151828d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Doc/library/itertools.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,12 @@ The following recipes have a more mathematical flavor:
10091009

10101010
.. testcode::
10111011

1012+
def multinomial(*counts):
1013+
"Number of distinct arrangements of a multiset."
1014+
# Counter('abracadabra').values() → 5 2 2 1 1
1015+
# multinomial(5, 2, 2, 1, 1) → 83160
1016+
return prod(map(comb, accumulate(counts), counts))
1017+
10121018
def powerset(iterable):
10131019
"Subsequences of the iterable from shortest to longest."
10141020
# powerset([1,2,3]) → () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)
@@ -1127,12 +1133,6 @@ The following recipes have a more mathematical flavor:
11271133
n -= n // prime
11281134
return n
11291135

1130-
def multinomial(*counts):
1131-
"Number of distinct arrangements of a multiset."
1132-
# Counter('abracadabra').values() → 5 2 2 1 1
1133-
# multinomial(5, 2, 2, 1, 1) → 83160
1134-
return prod(map(comb, accumulate(counts), counts))
1135-
11361136

11371137
.. doctest::
11381138
:hide:

0 commit comments

Comments
 (0)