@fraczak/k 4.0.3 → 4.0.4
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.
- package/README.md +158 -154
- package/k-repl.cast +1913 -0
- package/k-repl.cast~ +1939 -0
- package/k.cast +618 -0
- package/package.json +1 -1
- package/repl.mjs +2 -3
- package/run.mjs +3 -1
- package/TYPES.md +0 -32
- package/demo.cast +0 -1772
- package/demo.gif +0 -0
- package/demo2.cast +0 -1705
- package/demo_optimized.gif +0 -0
- package/sc.py +0 -25
package/package.json
CHANGED
package/repl.mjs
CHANGED
|
@@ -180,12 +180,11 @@ function evaluate(line) {
|
|
|
180
180
|
val = k.run(`+++\n${line}\n()`, val);
|
|
181
181
|
printVal();
|
|
182
182
|
} catch (error) {
|
|
183
|
-
|
|
184
|
-
console.error("ERROR:");
|
|
185
|
-
console.error(e);
|
|
183
|
+
console.error(error.message);
|
|
186
184
|
}
|
|
187
185
|
}
|
|
188
186
|
} catch (e) {
|
|
189
187
|
console.error(e.message);
|
|
188
|
+
console.error(e);
|
|
190
189
|
}
|
|
191
190
|
}
|
package/run.mjs
CHANGED
|
@@ -248,7 +248,9 @@ function run(exp, value) {
|
|
|
248
248
|
}
|
|
249
249
|
case "caret": {
|
|
250
250
|
const result = run(exp.caret, value);
|
|
251
|
-
assert(isOpen(result), "CARET (^): Only an 'open' vector can be closed.");
|
|
251
|
+
// assert(isOpen(result), "CARET (^): Only an 'open' vector can be closed.");
|
|
252
|
+
if (! isOpen(result))
|
|
253
|
+
throw new Error(`Type Error (line: ${exp.end?.line}:${exp.end?.column}): CARET (^): Only 'unboxed' values can be 'boxed'.`)
|
|
252
254
|
return [...result];
|
|
253
255
|
}
|
|
254
256
|
case "filter": {
|
package/TYPES.md
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# What if we concider partial functions as filter-to-filter mappings?
|
|
2
|
-
|
|
3
|
-
## Examples
|
|
4
|
-
|
|
5
|
-
```k
|
|
6
|
-
.x :: ( X x, ... ) -> X
|
|
7
|
-
{ f1 x1, f2 x2, ..., fn xn } :: X -> { f1(X) x1, f2(X) x2, ..., fn(X) xn }
|
|
8
|
-
{ f x } :: X -> < f(X) x, ... >
|
|
9
|
-
< f1, f2, ..., fn > :: X -> f1(X) // f1 == f2 == ... == fn
|
|
10
|
-
[ f1, f2, ..., fn ] :: X -> [f1(X)] // f1 == f2 == ... == fn
|
|
11
|
-
$code ::
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Let's consider the following example:
|
|
15
|
-
|
|
16
|
-
```k
|
|
17
|
-
$nat = < {} _, nat s >;
|
|
18
|
-
z = {{} _}; -- X -> <{} _, ...>
|
|
19
|
-
s = {() s}; -- X -> <X s, ...>
|
|
20
|
-
|
|
21
|
-
add =
|
|
22
|
-
<
|
|
23
|
-
{.x ._ if, .y then} .then,
|
|
24
|
-
{.x .s x, .y s y } add
|
|
25
|
-
>
|
|
26
|
-
;
|
|
27
|
-
|
|
28
|
-
double = {() x, () y} add;
|
|
29
|
-
|
|
30
|
-
z s s $nat double;
|
|
31
|
-
```
|
|
32
|
-
|