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
c7d7766f
Kaydet (Commit)
c7d7766f
authored
Agu 08, 2003
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Improve docs:
* Simplify the pure python examples * Add a quantify() example
üst
f5c96fb7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
16 deletions
+13
-16
libitertools.tex
Doc/lib/libitertools.tex
+13
-16
No files found.
Doc/lib/libitertools.tex
Dosyayı görüntüle @
c7d7766f
...
@@ -78,7 +78,7 @@ by functions or loops that truncate the stream.
...
@@ -78,7 +78,7 @@ by functions or loops that truncate the stream.
Make an iterator that returns consecutive integers starting with
\var
{
n
}
.
Make an iterator that returns consecutive integers starting with
\var
{
n
}
.
Does not currently support python long integers. Often used as an
Does not currently support python long integers. Often used as an
argument to
\function
{
imap()
}
to generate consecutive data points.
argument to
\function
{
imap()
}
to generate consecutive data points.
Also, used
in
\function
{
izip()
}
to add sequence numbers. Equivalent to:
Also, used
with
\function
{
izip()
}
to add sequence numbers. Equivalent to:
\begin{verbatim}
\begin{verbatim}
def count(n=0):
def count(n=0):
...
@@ -103,9 +103,7 @@ by functions or loops that truncate the stream.
...
@@ -103,9 +103,7 @@ by functions or loops that truncate the stream.
for element in iterable:
for element in iterable:
yield element
yield element
saved.append(element)
saved.append(element)
if len(saved) == 0:
while saved:
return
while True:
for element in saved:
for element in saved:
yield element
yield element
\end{verbatim}
\end{verbatim}
...
@@ -124,13 +122,12 @@ by functions or loops that truncate the stream.
...
@@ -124,13 +122,12 @@ by functions or loops that truncate the stream.
\begin{verbatim}
\begin{verbatim}
def dropwhile(predicate, iterable):
def dropwhile(predicate, iterable):
iterable = iter(iterable)
iterable = iter(iterable)
while True:
for x in iterable:
x = iterable.next()
if not predicate(x):
if predicate(x): continue # drop when predicate is true
yield x
break
for x in iterable:
yield x
yield x
break
while True:
yield iterable.next()
\end{verbatim}
\end{verbatim}
\end{funcdesc}
\end{funcdesc}
...
@@ -209,9 +206,7 @@ by functions or loops that truncate the stream.
...
@@ -209,9 +206,7 @@ by functions or loops that truncate the stream.
\begin{verbatim}
\begin{verbatim}
def islice(iterable, *args):
def islice(iterable, *args):
s = slice(*args)
s = slice(*args)
next = s.start or 0
next, stop, step = s.start or 0, s.stop, s.step or 1
stop = s.stop
step = s.step or 1
for cnt, element in enumerate(iterable):
for cnt, element in enumerate(iterable):
if cnt < next:
if cnt < next:
continue
continue
...
@@ -278,9 +273,7 @@ by functions or loops that truncate the stream.
...
@@ -278,9 +273,7 @@ by functions or loops that truncate the stream.
\begin{verbatim}
\begin{verbatim}
def takewhile(predicate, iterable):
def takewhile(predicate, iterable):
iterable = iter(iterable)
for x in iterable:
while True:
x = iterable.next()
if predicate(x):
if predicate(x):
yield x
yield x
else:
else:
...
@@ -358,6 +351,10 @@ from building blocks.
...
@@ -358,6 +351,10 @@ from building blocks.
... "Returns True if pred
(
x
)
is False for every element in the iterable"
... "Returns True if pred
(
x
)
is False for every element in the iterable"
... return True not in imap
(
pred, seq
)
... return True not in imap
(
pred, seq
)
>>> def quantify
(
pred, seq
)
:
... "Count how many times the predicate is True in the sequence"
... return sum
(
imap
(
pred, seq
))
>>> def padnone
(
seq
)
:
>>> def padnone
(
seq
)
:
... "Returns the sequence elements and then returns None indefinitely"
... "Returns the sequence elements and then returns None indefinitely"
... return chain
(
seq, repeat
(
None
))
... return chain
(
seq, repeat
(
None
))
...
...
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