Skip to content

Commit 35a7c2b

Browse files
committed
init
0 parents  commit 35a7c2b

File tree

14 files changed

+284
-0
lines changed

14 files changed

+284
-0
lines changed

.gitignore

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
db.sqlite3
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# Environments
85+
.env
86+
.venv
87+
env/
88+
venv/
89+
ENV/
90+
env.bak/
91+
venv.bak/
92+
93+
# Spyder project settings
94+
.spyderproject
95+
.spyproject
96+
97+
# Rope project settings
98+
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
.idea/

python/Data/Bounded.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import sys
2+
3+
topInt = 2147483647
4+
bottomInt = -2147483648
5+
topChar = chr(65535)
6+
bottomChar = chr(0)
7+
8+
topNumber = sys.float_info.max
9+
bottomNumber = sys.float_info.min

python/Data/Eq.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def refEq(r1):
2+
return lambda r2: r1 is r2
3+
4+
5+
def structEq(r1):
6+
return lambda r2: r1 == r2
7+
8+
9+
eqBooleanImpl = refEq
10+
eqIntImpl = eqNumberImpl = eqCharImpl = eqStringImpl = structEq
11+
12+
13+
def eqArrayImpl(f):
14+
def eq_arr1(xs):
15+
def eq_arr2(ys):
16+
if len(xs) != len(ys):
17+
return False
18+
for x, y in zip(xs, ys):
19+
if not f(x)(y):
20+
return False
21+
return True
22+
23+
return eq_arr2
24+
25+
return eq_arr1

python/Data/EuclideanRing.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def intDegree(x):
2+
return min(abs(x), 2147483647)
3+
4+
5+
def intDiv(x):
6+
return lambda y: (
7+
0 if y is 0 else
8+
x // y if y > 0 else
9+
x // -y
10+
)
11+
12+
13+
def intMod(x):
14+
return lambda y: (
15+
0 if y is 0 else
16+
x % abs(y)
17+
)
18+
19+
20+
def numDiv(n1):
21+
return lambda n2: n1 / n2

python/Data/Functor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def arrayMap(f):
2+
def app(arr):
3+
return tuple(f(e) for e in arr)
4+
5+
return app

python/Data/HeytingAlgebra.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def boolConj(b1):
2+
return lambda b2: b1 and b2
3+
4+
5+
def boolDisj(b1):
6+
return lambda b2: b1 or b2
7+
8+
9+
def boolNot(b):
10+
return not b

python/Data/Ord.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
unsafeCompareImpl = lambda lt: lambda eq: lambda gt: lambda x: lambda y: (
2+
lt if x < y else
3+
eq if x == y else
4+
gt
5+
)
6+
7+
unsafeCompareImplStruct = lambda lt: lambda eq: lambda gt: lambda x: lambda y: (
8+
lt if x < y else
9+
eq if x == y else
10+
gt
11+
)
12+
13+
ordBooleanImpl = unsafeCompareImplStruct
14+
ordIntImpl = ordNumberImpl = ordStringImpl = ordCharImpl = unsafeCompareImpl
15+
16+
17+
def ordArrayImpl(f):
18+
def ap1(xs):
19+
def ap2(ys):
20+
for x, y in zip(xs, ys):
21+
o = f(x)(y)
22+
if o is not 0:
23+
return o
24+
xlen = len(xs)
25+
ylen = len(ys)
26+
if xlen == ylen:
27+
return 0
28+
if xlen > ylen:
29+
return -1
30+
return 1
31+
32+
return ap2
33+
34+
return ap1

python/Data/Ord/Unsafe.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
unsafeCompareImpl = lambda lt: lambda eq: lambda gt: lambda x: lambda y: (
2+
lt if x < y else
3+
eq if x == y else
4+
gt
5+
)

python/Data/Ring.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def intSub(x):
2+
return lambda y: x - y
3+
4+
5+
def numSub(x):
6+
return lambda y: x - y

python/Data/Semigroup.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def concatString(s1):
2+
return lambda s2: s1 + s2
3+
4+
5+
def concatArray(xs):
6+
return lambda ys: (
7+
ys if not xs else
8+
xs if not ys else
9+
xs + ys
10+
)

0 commit comments

Comments
 (0)