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
f77d0334
Kaydet (Commit)
f77d0334
authored
Mar 11, 2005
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Revised the itertools quantifier recipes to match the performance of the
new builtins.
üst
96229b19
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
libitertools.tex
Doc/lib/libitertools.tex
+8
-8
test_itertools.py
Lib/test/test_itertools.py
+8
-8
No files found.
Doc/lib/libitertools.tex
Dosyayı görüntüle @
f77d0334
...
...
@@ -461,26 +461,26 @@ def nth(iterable, n):
"Returns the nth item"
return list
(
islice
(
iterable, n, n
+
1
))
def all
(
seq, pred
=
bool
)
:
"Returns True if pred
(
x
)
is
T
rue for every element in the iterable"
def all
(
seq, pred
=
None
)
:
"Returns True if pred
(
x
)
is
t
rue for every element in the iterable"
for elem in ifilterfalse
(
pred, seq
)
:
return False
return True
def any
(
seq, pred
=
bool
)
:
"Returns True if pred
(
x
)
is
T
rue for at least one element in the iterable"
def any
(
seq, pred
=
None
)
:
"Returns True if pred
(
x
)
is
t
rue for at least one element in the iterable"
for elem in ifilter
(
pred, seq
)
:
return True
return False
def no
(
seq, pred
=
bool
)
:
"Returns True if pred
(
x
)
is
F
alse for every element in the iterable"
def no
(
seq, pred
=
None
)
:
"Returns True if pred
(
x
)
is
f
alse for every element in the iterable"
for elem in ifilter
(
pred, seq
)
:
return False
return True
def quantify
(
seq, pred
=
bool
)
:
"Count how many times the predicate is
T
rue in the sequence"
def quantify
(
seq, pred
=
None
)
:
"Count how many times the predicate is
t
rue in the sequence"
return sum
(
imap
(
pred, seq
))
def padnone
(
seq
)
:
...
...
Lib/test/test_itertools.py
Dosyayı görüntüle @
f77d0334
...
...
@@ -799,26 +799,26 @@ Samuele
... "Returns the nth item"
... return list(islice(iterable, n, n+1))
>>> def all(seq, pred=
bool
):
... "Returns True if pred(x) is
T
rue for every element in the iterable"
>>> def all(seq, pred=
None
):
... "Returns True if pred(x) is
t
rue for every element in the iterable"
... for elem in ifilterfalse(pred, seq):
... return False
... return True
>>> def any(seq, pred=
bool
):
... "Returns True if pred(x) is
T
rue for at least one element in the iterable"
>>> def any(seq, pred=
None
):
... "Returns True if pred(x) is
t
rue for at least one element in the iterable"
... for elem in ifilter(pred, seq):
... return True
... return False
>>> def no(seq, pred=
bool
):
... "Returns True if pred(x) is
F
alse for every element in the iterable"
>>> def no(seq, pred=
None
):
... "Returns True if pred(x) is
f
alse for every element in the iterable"
... for elem in ifilter(pred, seq):
... return False
... return True
>>> def quantify(seq, pred=
bool
):
... "Count how many times the predicate is
T
rue in the sequence"
>>> def quantify(seq, pred=
None
):
... "Count how many times the predicate is
t
rue in the sequence"
... return sum(imap(pred, seq))
>>> def padnone(seq):
...
...
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