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
762c39e9
Kaydet (Commit)
762c39e9
authored
Ock 01, 1991
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Initial revision
üst
b5e05e95
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
129 additions
and
0 deletions
+129
-0
fnmatch.py
Lib/fnmatch.py
+35
-0
zmod.py
Lib/zmod.py
+94
-0
No files found.
Lib/fnmatch.py
0 → 100644
Dosyayı görüntüle @
762c39e9
# module 'fnmatch' -- filename matching with shell patterns
# XXX [] patterns are not supported (but recognized)
def
fnmatch
(
name
,
pat
):
if
'*'
in
pat
or
'?'
in
pat
or
'['
in
pat
:
return
fnmatch1
(
name
,
pat
)
return
name
=
pat
def
fnmatch1
(
name
,
pat
):
for
i
in
range
(
len
(
pat
)):
c
=
pat
[
i
]
if
c
=
'*'
:
restpat
=
pat
[
i
+
1
:]
if
'*'
in
restpat
or
'?'
in
restpat
or
'['
in
restpat
:
for
i
in
range
(
i
,
len
(
name
)):
if
fnmatch1
(
name
[
i
:],
restpat
):
return
1
return
0
else
:
return
name
[
len
(
name
)
-
len
(
restpat
):]
=
restpat
elif
c
=
'?'
:
if
len
(
name
)
<=
i
:
return
0
elif
c
=
'['
:
return
0
# XXX
else
:
if
name
[
i
:
i
+
1
]
<>
c
:
return
0
return
1
def
fnmatchlist
(
names
,
pat
):
res
=
[]
for
name
in
names
:
if
fnmatch
(
name
,
pat
):
res
.
append
(
name
)
return
res
Lib/zmod.py
0 → 100644
Dosyayı görüntüle @
762c39e9
# module 'zmod'
# Compute properties of mathematical "fields" formed by taking
# Z/n (the whole numbers modulo some whole number n) and an
# irreducible polynomial (i.e., a polynomial with only complex zeros),
# e.g., Z/5 and X**2 + 2.
#
# The field is formed by taking all possible linear combinations of
# a set of d base vectors (where d is the degree of the polynomial).
#
# Note that this procedure doesn't yield a field for all combinations
# of n and p: it may well be that some numbers have more than one
# inverse and others have none. This is what we check.
#
# Remember that a field is a ring where each element has an inverse.
# A ring has commutative addition and multiplication, a zero and a one:
# 0*x = x*0 = 0, 0+x = x+0 = x, 1*x = x*1 = x. Also, the distributive
# property holds: a*(b+c) = a*b + b*c.
# (XXX I forget if this is an axiom or follows from the rules.)
import
poly
# Example N and polynomial
N
=
5
P
=
poly
.
plus
(
poly
.
one
(
0
,
2
),
poly
.
one
(
2
,
1
))
# 2 + x**2
# Return x modulo y. Returns >= 0 even if x < 0.
def
mod
(
x
,
y
):
return
divmod
(
x
,
y
)[
1
]
# Normalize a polynomial modulo n and modulo p.
def
norm
(
a
,
n
,
p
):
a
=
poly
.
modulo
(
a
,
p
)
a
=
a
[:]
for
i
in
range
(
len
(
a
)):
a
[
i
]
=
mod
(
a
[
i
],
n
)
a
=
poly
.
normalize
(
a
)
return
a
# Make a list of all n^d elements of the proposed field.
def
make_all
(
mat
):
all
=
[]
for
row
in
mat
:
for
a
in
row
:
all
.
append
(
a
)
return
all
def
make_elements
(
n
,
d
):
if
d
=
0
:
return
[
poly
.
one
(
0
,
0
)]
sub
=
make_elements
(
n
,
d
-
1
)
all
=
[]
for
a
in
sub
:
for
i
in
range
(
n
):
all
.
append
(
poly
.
plus
(
a
,
poly
.
one
(
d
-
1
,
i
)))
return
all
def
make_inv
(
all
,
n
,
p
):
x
=
poly
.
one
(
1
,
1
)
inv
=
[]
for
a
in
all
:
inv
.
append
(
norm
(
poly
.
times
(
a
,
x
),
n
,
p
))
return
inv
def
checkfield
(
n
,
p
):
all
=
make_elements
(
n
,
len
(
p
)
-
1
)
inv
=
make_inv
(
all
,
n
,
p
)
all1
=
all
[:]
inv1
=
inv
[:]
all1
.
sort
()
inv1
.
sort
()
if
all1
=
inv1
:
print
'BINGO!'
else
:
print
'Sorry:'
,
n
,
p
print
all
print
inv
def
rj
(
s
,
width
):
if
type
(
s
)
<>
type
(
''
):
s
=
`s`
n
=
len
(
s
)
if
n
>=
width
:
return
s
return
' '
*
(
width
-
n
)
+
s
def
lj
(
s
,
width
):
if
type
(
s
)
<>
type
(
''
):
s
=
`s`
n
=
len
(
s
)
if
n
>=
width
:
return
s
return
s
+
' '
*
(
width
-
n
)
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