@dallaylaen/ski-interpreter 2.3.1 → 2.3.3
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/CHANGELOG.md +18 -0
- package/lib/ski-interpreter.cjs.js +28 -0
- package/lib/ski-interpreter.cjs.js.map +2 -2
- package/lib/ski-interpreter.esm.js +28 -0
- package/lib/ski-interpreter.esm.js.map +2 -2
- package/lib/ski-interpreter.min.js +3 -3
- package/lib/ski-interpreter.min.js.map +3 -3
- package/lib/ski-quest.min.js +2 -2
- package/lib/ski-quest.min.js.map +3 -3
- package/package.json +1 -1
- package/types/src/expr.d.ts +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.3.3] - 2026-03-01
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- `SKI.extras.foldr` is now removed in favor of
|
|
13
|
+
`Expr.foldBottomUp<T>(fun: (expr: Expr, args: T[]) => T): T`
|
|
14
|
+
with the same semantics but more descriptive name
|
|
15
|
+
and simpler signature.
|
|
16
|
+
_Was experimental (and still is), so not considered a breaking change._
|
|
17
|
+
|
|
18
|
+
## [2.3.2] - 2026-03-01
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- `SKI.extras.foldr(expr: Expr, fun: (expr: Expr, args: T[]) => T): T` (experimental) -
|
|
23
|
+
apply function `fun` to every term in root position in a subexpression,
|
|
24
|
+
followed by the result of folding its arguments.
|
|
25
|
+
|
|
8
26
|
## [2.3.1] - 2026-03-01
|
|
9
27
|
|
|
10
28
|
### Fixed
|
|
@@ -292,6 +292,34 @@ var require_expr = __commonJS({
|
|
|
292
292
|
const [value, _] = unwrap(this._fold(initial, combine));
|
|
293
293
|
return value ?? initial;
|
|
294
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* @experimental
|
|
297
|
+
* @desc Fold an application tree bottom to top.
|
|
298
|
+
* For each subtree, the function is given the term in the root position and
|
|
299
|
+
* a list of the results of folding its arguments.
|
|
300
|
+
*
|
|
301
|
+
* E.g. fold('x y (z t)', f) results in f(x, [f(y, []), f(z, [f(t, [])])])
|
|
302
|
+
*
|
|
303
|
+
* @example expr.foldBottomUp((head, tail) => {
|
|
304
|
+
* if (head.arity && head.arity <= tail.length) {
|
|
305
|
+
* return '(<span class="redex">'
|
|
306
|
+
* + head + ' '
|
|
307
|
+
* + tail.slice(0, head.arity).join(' ')
|
|
308
|
+
* + '</span>'
|
|
309
|
+
* + tail.slice(head.arity).join(' ')
|
|
310
|
+
* + ')';
|
|
311
|
+
* } else {
|
|
312
|
+
* return '(' + head + ' ' + tail.join(' ') + ')';
|
|
313
|
+
* }
|
|
314
|
+
* });
|
|
315
|
+
* @template T
|
|
316
|
+
* @param {(head: Expr, tail: T[]) => T} fun
|
|
317
|
+
* @return {T}
|
|
318
|
+
*/
|
|
319
|
+
foldBottomUp(fun) {
|
|
320
|
+
const [head, ...tail] = this.unroll();
|
|
321
|
+
return fun(head, tail.map((e) => e.foldBottomUp(fun)));
|
|
322
|
+
}
|
|
295
323
|
/**
|
|
296
324
|
* @template T
|
|
297
325
|
* @param {T} initial
|