@calcit/procs 0.7.7 → 0.7.9
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/lib/calcit.procs.mjs +16 -30
- package/lib/js-set.mjs +5 -10
- package/package.json +1 -1
- package/ts-src/calcit.procs.mts +17 -29
- package/ts-src/js-set.mts +5 -11
package/lib/calcit.procs.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
// CALCIT VERSION
|
|
3
|
-
export const calcit_version = "0.7.
|
|
3
|
+
export const calcit_version = "0.7.9";
|
|
4
4
|
import { parse } from "@cirru/parser.ts";
|
|
5
5
|
import { writeCirruCode } from "@cirru/writer.ts";
|
|
6
6
|
import { CalcitSymbol, CalcitTag, CalcitRef, CalcitRecur, newTag, refsRegistry, toString, getStringName, _$n__$e_, hashFunction, } from "./calcit-data.mjs";
|
|
@@ -256,6 +256,11 @@ export let _$n_tuple_$o_class = function (x) {
|
|
|
256
256
|
throw new Error("&tuple:class takes 1 argument");
|
|
257
257
|
return x.klass;
|
|
258
258
|
};
|
|
259
|
+
export let _$n_tuple_$o_params = function (x) {
|
|
260
|
+
if (arguments.length !== 1)
|
|
261
|
+
throw new Error("&tuple:params takes 1 argument");
|
|
262
|
+
return new CalcitSliceList(x.extra);
|
|
263
|
+
};
|
|
259
264
|
export let _$n_tuple_$o_with_class = function (x, y) {
|
|
260
265
|
if (arguments.length !== 2)
|
|
261
266
|
throw new Error("&tuple:with-class takes 2 arguments");
|
|
@@ -436,12 +441,13 @@ export let _$n_str_$o_first = (xs) => {
|
|
|
436
441
|
console.error(xs);
|
|
437
442
|
throw new Error("Expected a string");
|
|
438
443
|
};
|
|
439
|
-
export let _$n_map_$
|
|
444
|
+
export let _$n_map_$o_destruct = (xs) => {
|
|
440
445
|
if (xs instanceof CalcitMap || xs instanceof CalcitSliceMap) {
|
|
441
|
-
//
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
446
|
+
// order not stable
|
|
447
|
+
if (xs.len() > 0) {
|
|
448
|
+
let pair = xs.pairs()[0];
|
|
449
|
+
let k0 = pair[0];
|
|
450
|
+
return new CalcitSliceList([new CalcitSliceList(pair), xs.dissoc(k0)]);
|
|
445
451
|
}
|
|
446
452
|
else {
|
|
447
453
|
return null;
|
|
@@ -450,12 +456,11 @@ export let _$n_map_$o_first = (xs) => {
|
|
|
450
456
|
console.error(xs);
|
|
451
457
|
throw new Error("Expected a map");
|
|
452
458
|
};
|
|
453
|
-
export let _$n_set_$
|
|
454
|
-
if (xs instanceof CalcitSet)
|
|
455
|
-
return xs.
|
|
456
|
-
}
|
|
459
|
+
export let _$n_set_$o_destruct = (xs) => {
|
|
460
|
+
if (xs instanceof CalcitSet)
|
|
461
|
+
return xs.destruct();
|
|
457
462
|
console.error(xs);
|
|
458
|
-
throw new Error("
|
|
463
|
+
throw new Error("Expect a set");
|
|
459
464
|
};
|
|
460
465
|
export let timeout_call = (duration, f) => {
|
|
461
466
|
if (typeof duration !== "number") {
|
|
@@ -483,25 +488,6 @@ export let _$n_str_$o_rest = (xs) => {
|
|
|
483
488
|
console.error(xs);
|
|
484
489
|
throw new Error("Expects a string");
|
|
485
490
|
};
|
|
486
|
-
export let _$n_set_$o_rest = (xs) => {
|
|
487
|
-
if (xs instanceof CalcitSet)
|
|
488
|
-
return xs.rest();
|
|
489
|
-
console.error(xs);
|
|
490
|
-
throw new Error("Expect a set");
|
|
491
|
-
};
|
|
492
|
-
export let _$n_map_$o_rest = (xs) => {
|
|
493
|
-
if (xs instanceof CalcitMap || xs instanceof CalcitSliceMap) {
|
|
494
|
-
if (xs.len() > 0) {
|
|
495
|
-
let k0 = xs.pairs()[0][0];
|
|
496
|
-
return xs.dissoc(k0);
|
|
497
|
-
}
|
|
498
|
-
else {
|
|
499
|
-
return new CalcitSliceMap([]);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
console.error(xs);
|
|
503
|
-
throw new Error("Expected map");
|
|
504
|
-
};
|
|
505
491
|
export let recur = (...xs) => {
|
|
506
492
|
return new CalcitRecur(xs);
|
|
507
493
|
};
|
package/lib/js-set.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { toString } from "./calcit-data.mjs";
|
|
2
2
|
import { mapLen, assocMap, dissocMap, toPairsArray, contains, initTernaryTreeMapFromArray, initEmptyTernaryTreeMap, } from "@calcit/ternary-tree";
|
|
3
3
|
import * as ternaryTree from "@calcit/ternary-tree";
|
|
4
|
+
import { CalcitSliceList } from "./js-list.mjs";
|
|
4
5
|
/** need to compare by Calcit */
|
|
5
6
|
let DATA_EQUAL = (x, y) => {
|
|
6
7
|
return x === y;
|
|
@@ -67,20 +68,14 @@ export class CalcitSet {
|
|
|
67
68
|
}
|
|
68
69
|
return new CalcitSet(result);
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
// rather suspicious solution since set has no logical order
|
|
71
|
+
destruct() {
|
|
72
72
|
if (mapLen(this.value) === 0) {
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
rest() {
|
|
78
|
-
if (mapLen(this.value) === 0) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
let x0 = this.first();
|
|
75
|
+
// rather suspicious solution since set has no logical order
|
|
76
|
+
let x0 = toPairsArray(this.value)[0][0];
|
|
82
77
|
let result = dissocMap(this.value, x0);
|
|
83
|
-
return new CalcitSet(result);
|
|
78
|
+
return new CalcitSliceList([x0, new CalcitSet(result)]);
|
|
84
79
|
}
|
|
85
80
|
toString(disableJsDataWarning = false) {
|
|
86
81
|
let itemsCode = "";
|
package/package.json
CHANGED
package/ts-src/calcit.procs.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// CALCIT VERSION
|
|
2
|
-
export const calcit_version = "0.7.
|
|
2
|
+
export const calcit_version = "0.7.9";
|
|
3
3
|
|
|
4
4
|
import { parse, ICirruNode } from "@cirru/parser.ts";
|
|
5
5
|
import { writeCirruCode } from "@cirru/writer.ts";
|
|
@@ -303,6 +303,11 @@ export let _$n_tuple_$o_class = function (x: CalcitTuple) {
|
|
|
303
303
|
return x.klass;
|
|
304
304
|
};
|
|
305
305
|
|
|
306
|
+
export let _$n_tuple_$o_params = function (x: CalcitTuple) {
|
|
307
|
+
if (arguments.length !== 1) throw new Error("&tuple:params takes 1 argument");
|
|
308
|
+
return new CalcitSliceList(x.extra);
|
|
309
|
+
};
|
|
310
|
+
|
|
306
311
|
export let _$n_tuple_$o_with_class = function (x: CalcitTuple, y: CalcitRecord) {
|
|
307
312
|
if (arguments.length !== 2) throw new Error("&tuple:with-class takes 2 arguments");
|
|
308
313
|
if (!(x instanceof CalcitTuple)) throw new Error("&tuple:with-class expects a tuple");
|
|
@@ -492,12 +497,14 @@ export let _$n_str_$o_first = (xs: CalcitValue): CalcitValue => {
|
|
|
492
497
|
console.error(xs);
|
|
493
498
|
throw new Error("Expected a string");
|
|
494
499
|
};
|
|
495
|
-
|
|
500
|
+
|
|
501
|
+
export let _$n_map_$o_destruct = (xs: CalcitValue): CalcitValue => {
|
|
496
502
|
if (xs instanceof CalcitMap || xs instanceof CalcitSliceMap) {
|
|
497
|
-
//
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
503
|
+
// order not stable
|
|
504
|
+
if (xs.len() > 0) {
|
|
505
|
+
let pair = xs.pairs()[0];
|
|
506
|
+
let k0 = pair[0];
|
|
507
|
+
return new CalcitSliceList([new CalcitSliceList(pair), xs.dissoc(k0)]);
|
|
501
508
|
} else {
|
|
502
509
|
return null;
|
|
503
510
|
}
|
|
@@ -505,13 +512,12 @@ export let _$n_map_$o_first = (xs: CalcitValue): CalcitValue => {
|
|
|
505
512
|
console.error(xs);
|
|
506
513
|
throw new Error("Expected a map");
|
|
507
514
|
};
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
}
|
|
515
|
+
|
|
516
|
+
export let _$n_set_$o_destruct = (xs: CalcitValue): CalcitValue => {
|
|
517
|
+
if (xs instanceof CalcitSet) return xs.destruct();
|
|
512
518
|
|
|
513
519
|
console.error(xs);
|
|
514
|
-
throw new Error("
|
|
520
|
+
throw new Error("Expect a set");
|
|
515
521
|
};
|
|
516
522
|
|
|
517
523
|
export let timeout_call = (duration: number, f: CalcitFn): null => {
|
|
@@ -542,24 +548,6 @@ export let _$n_str_$o_rest = (xs: CalcitValue): CalcitValue => {
|
|
|
542
548
|
console.error(xs);
|
|
543
549
|
throw new Error("Expects a string");
|
|
544
550
|
};
|
|
545
|
-
export let _$n_set_$o_rest = (xs: CalcitValue): CalcitValue => {
|
|
546
|
-
if (xs instanceof CalcitSet) return xs.rest();
|
|
547
|
-
|
|
548
|
-
console.error(xs);
|
|
549
|
-
throw new Error("Expect a set");
|
|
550
|
-
};
|
|
551
|
-
export let _$n_map_$o_rest = (xs: CalcitValue): CalcitValue => {
|
|
552
|
-
if (xs instanceof CalcitMap || xs instanceof CalcitSliceMap) {
|
|
553
|
-
if (xs.len() > 0) {
|
|
554
|
-
let k0 = xs.pairs()[0][0];
|
|
555
|
-
return xs.dissoc(k0);
|
|
556
|
-
} else {
|
|
557
|
-
return new CalcitSliceMap([]);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
console.error(xs);
|
|
561
|
-
throw new Error("Expected map");
|
|
562
|
-
};
|
|
563
551
|
|
|
564
552
|
export let recur = (...xs: CalcitValue[]): CalcitRecur => {
|
|
565
553
|
return new CalcitRecur(xs);
|
package/ts-src/js-set.mts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
initEmptyTernaryTreeMap,
|
|
16
16
|
} from "@calcit/ternary-tree";
|
|
17
17
|
import * as ternaryTree from "@calcit/ternary-tree";
|
|
18
|
+
import { CalcitSliceList } from "./js-list.mjs";
|
|
18
19
|
|
|
19
20
|
/** need to compare by Calcit */
|
|
20
21
|
let DATA_EQUAL = (x: CalcitValue, y: CalcitValue): boolean => {
|
|
@@ -87,22 +88,15 @@ export class CalcitSet {
|
|
|
87
88
|
return new CalcitSet(result);
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
// rather suspicious solution since set has no logical order
|
|
92
|
-
|
|
91
|
+
destruct(): CalcitSliceList {
|
|
93
92
|
if (mapLen(this.value) === 0) {
|
|
94
93
|
return null;
|
|
95
94
|
}
|
|
95
|
+
// rather suspicious solution since set has no logical order
|
|
96
|
+
let x0 = toPairsArray(this.value)[0][0];
|
|
96
97
|
|
|
97
|
-
return toPairsArray(this.value)[0][0];
|
|
98
|
-
}
|
|
99
|
-
rest(): CalcitSet {
|
|
100
|
-
if (mapLen(this.value) === 0) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
let x0 = this.first();
|
|
104
98
|
let result = dissocMap(this.value, x0);
|
|
105
|
-
return new CalcitSet(result);
|
|
99
|
+
return new CalcitSliceList([x0, new CalcitSet(result)]);
|
|
106
100
|
}
|
|
107
101
|
|
|
108
102
|
toString(disableJsDataWarning: boolean = false) {
|