https://github.com/python/cpython/commit/741c6386b8615fbfb4f2e6027556751039119950 commit: 741c6386b8615fbfb4f2e6027556751039119950 branch: main author: Raymond Hettinger <rhettin...@users.noreply.github.com> committer: rhettinger <rhettin...@users.noreply.github.com> date: 2025-04-18T12:41:13-05:00 summary:
Minor doc edit: Make multinomial() the first math example (gh-132697) files: M Doc/library/itertools.rst diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 438f3db60c396d..00925ae920aad9 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -1009,6 +1009,12 @@ The following recipes have a more mathematical flavor: .. testcode:: + def multinomial(*counts): + "Number of distinct arrangements of a multiset." + # Counter('abracadabra').values() → 5 2 2 1 1 + # multinomial(5, 2, 2, 1, 1) → 83160 + return prod(map(comb, accumulate(counts), counts)) + def powerset(iterable): "Subsequences of the iterable from shortest to longest." # 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: n -= n // prime return n - def multinomial(*counts): - "Number of distinct arrangements of a multiset." - # Counter('abracadabra').values() → 5 2 2 1 1 - # multinomial(5, 2, 2, 1, 1) → 83160 - return prod(map(comb, accumulate(counts), counts)) - .. doctest:: :hide: _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com