curryparty 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {curryparty-0.2.2 → curryparty-0.2.3}/PKG-INFO +1 -1
- {curryparty-0.2.2 → curryparty-0.2.3}/pyproject.toml +1 -1
- {curryparty-0.2.2 → curryparty-0.2.3}/src/curryparty/__init__.py +23 -5
- {curryparty-0.2.2 → curryparty-0.2.3}/README.md +0 -0
- {curryparty-0.2.2 → curryparty-0.2.3}/src/curryparty/core.py +0 -0
- {curryparty-0.2.2 → curryparty-0.2.3}/src/curryparty/display.py +0 -0
- {curryparty-0.2.2 → curryparty-0.2.3}/src/curryparty/py.typed +0 -0
- {curryparty-0.2.2 → curryparty-0.2.3}/src/curryparty/utils.py +0 -0
|
@@ -6,9 +6,10 @@ except ImportError:
|
|
|
6
6
|
raise ImportError(
|
|
7
7
|
"curryparty needs the `polars` library. \n Please install it, typically with `pip install polars`"
|
|
8
8
|
)
|
|
9
|
-
from svg import SVG, Rect
|
|
10
9
|
import uuid
|
|
11
10
|
|
|
11
|
+
from svg import SVG, Rect
|
|
12
|
+
|
|
12
13
|
from .core import SCHEMA, beta_reduce, compose, find_redexes, find_variables, subtree
|
|
13
14
|
from .display import (
|
|
14
15
|
compute_height,
|
|
@@ -116,7 +117,7 @@ class Term:
|
|
|
116
117
|
).as_str()
|
|
117
118
|
|
|
118
119
|
return Html(
|
|
119
|
-
f
|
|
120
|
+
f'<div><div style="margin:5px">click to animate, move away and back to reset</div>{anim_svg}</div>'
|
|
120
121
|
)
|
|
121
122
|
|
|
122
123
|
def _repr_html_(self, x0=-10, width=30):
|
|
@@ -136,6 +137,12 @@ class Term:
|
|
|
136
137
|
).as_str()
|
|
137
138
|
|
|
138
139
|
|
|
140
|
+
def offset_var(x: Union[int, str], offset: int) -> Union[int, str]:
|
|
141
|
+
if isinstance(x, int):
|
|
142
|
+
return x + offset
|
|
143
|
+
return x
|
|
144
|
+
|
|
145
|
+
|
|
139
146
|
class L:
|
|
140
147
|
def __init__(self, *lambda_names):
|
|
141
148
|
self.n = len(lambda_names)
|
|
@@ -153,7 +160,7 @@ class L:
|
|
|
153
160
|
if isinstance(t, L):
|
|
154
161
|
offset = self.n
|
|
155
162
|
for i, x in t.refs:
|
|
156
|
-
self.refs.append((offset + i, t.lambdas.get(x, x)))
|
|
163
|
+
self.refs.append((offset + i, offset_var(t.lambdas.get(x, x), offset)))
|
|
157
164
|
|
|
158
165
|
for i, x in t.args:
|
|
159
166
|
self.args.append((offset + i, offset + x))
|
|
@@ -170,7 +177,10 @@ class L:
|
|
|
170
177
|
|
|
171
178
|
def call(self, arg: Union[str, "L"]) -> "L":
|
|
172
179
|
assert self.last_ is not None
|
|
173
|
-
self.refs = [
|
|
180
|
+
self.refs = [
|
|
181
|
+
(i + 1, offset_var(x, 1)) if i >= self.last_ else (i, x)
|
|
182
|
+
for (i, x) in self.refs
|
|
183
|
+
]
|
|
174
184
|
self.args = [
|
|
175
185
|
(i + 1, x + 1) if i >= self.last_ else (i, x) for (i, x) in self.args
|
|
176
186
|
]
|
|
@@ -182,7 +192,15 @@ class L:
|
|
|
182
192
|
return self
|
|
183
193
|
|
|
184
194
|
def build(self) -> "Term":
|
|
185
|
-
|
|
195
|
+
def bind_var(x: Union[str, int]) -> int:
|
|
196
|
+
# check that all remaining unbound variables are bound to this lambda
|
|
197
|
+
if isinstance(x, int):
|
|
198
|
+
return x
|
|
199
|
+
if x not in self.lambdas:
|
|
200
|
+
raise ValueError(f"variable {x} is not bound to any lambda")
|
|
201
|
+
return self.lambdas[x]
|
|
202
|
+
|
|
203
|
+
self.refs = [(i, bind_var(x)) for i, x in self.refs]
|
|
186
204
|
ref = pl.from_records(
|
|
187
205
|
self.refs, orient="row", schema={"id": pl.UInt32, "ref": pl.UInt32}
|
|
188
206
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|