Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
2d93e6ee
Kaydet (Commit)
2d93e6ee
authored
Ara 03, 2010
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Update the itertools.accumulate() docs.
üst
240f1124
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
itertools.rst
Doc/library/itertools.rst
+4
-5
test_itertools.py
Lib/test/test_itertools.py
+1
-0
No files found.
Doc/library/itertools.rst
Dosyayı görüntüle @
2d93e6ee
...
...
@@ -46,7 +46,7 @@ Iterator Arguments Results
==================== ============================ ================================================= =============================================================
Iterator Arguments Results Example
==================== ============================ ================================================= =============================================================
:func:`accumulate` p
[, start=0]
p0, p0+p1, p0+p1+p2, ... ``accumulate([1,2,3,4,5]) --> 1 3 6 10 15``
:func:`accumulate` p
p0, p0+p1, p0+p1+p2, ... ``accumulate([1,2,3,4,5]) --> 1 3 6 10 15``
:func:`chain` p, q, ... p0, p1, ... plast, q0, q1, ... ``chain('ABC', 'DEF') --> A B C D E F``
:func:`compress` data, selectors (d[0] if s[0]), (d[1] if s[1]), ... ``compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F``
:func:`dropwhile` pred, seq seq[n], seq[n+1], starting when pred fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1``
...
...
@@ -84,11 +84,10 @@ The following module functions all construct and return iterators. Some provide
streams of infinite length, so they should only be accessed by functions or
loops that truncate the stream.
.. function:: accumulate(iterable
, start=0
)
.. function:: accumulate(iterable)
Make an iterator that returns accumulated sums plus the value of the *start*
parameter (which defaults to :const:`0`). Elements may be any addable type
including :class:`Decimal` or :class:`Fraction`. Equivalent to::
Make an iterator that returns accumulated sums. Elements may be any addable
type including :class:`Decimal` or :class:`Fraction`. Equivalent to::
def accumulate(iterable):
'Return running totals'
...
...
Lib/test/test_itertools.py
Dosyayı görüntüle @
2d93e6ee
...
...
@@ -66,6 +66,7 @@ class TestBasicOps(unittest.TestCase):
self
.
assertEqual
(
list
(
accumulate
(
map
(
typ
,
range
(
10
)))),
list
(
map
(
typ
,
[
0
,
1
,
3
,
6
,
10
,
15
,
21
,
28
,
36
,
45
])))
self
.
assertEqual
(
list
(
accumulate
(
'abc'
)),
[
'a'
,
'ab'
,
'abc'
])
# works with non-numeric
self
.
assertEqual
(
list
(
accumulate
([])),
[])
# empty iterable
self
.
assertEqual
(
list
(
accumulate
([
7
])),
[
7
])
# iterable of length one
self
.
assertRaises
(
TypeError
,
accumulate
,
range
(
10
),
5
)
# too many args
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment