@dallaylaen/ski-interpreter 2.3.2 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dallaylaen/ski-interpreter",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "description": "Simple Kombinator Interpreter - a combinatory logic & lambda calculus parser and interpreter. Supports SKI, BCKW, Church numerals, and setting up assertions ('quests') involving all of the above.",
5
5
  "keywords": [
6
6
  "combinatory logic",
@@ -159,6 +159,31 @@ export class Expr {
159
159
  * @returns {T}
160
160
  */
161
161
  fold<T_1>(initial: T_1, combine: (acc: T_1, expr: Expr) => TraverseValue<T_1>): T_1;
162
+ /**
163
+ * @experimental
164
+ * @desc Fold an application tree bottom to top.
165
+ * For each subtree, the function is given the term in the root position and
166
+ * a list of the results of folding its arguments.
167
+ *
168
+ * E.g. fold('x y (z t)', f) results in f(x, [f(y, []), f(z, [f(t, [])])])
169
+ *
170
+ * @example expr.foldBottomUp((head, tail) => {
171
+ * if (head.arity && head.arity <= tail.length) {
172
+ * return '(<span class="redex">'
173
+ * + head + ' '
174
+ * + tail.slice(0, head.arity).join(' ')
175
+ * + '</span>'
176
+ * + tail.slice(head.arity).join(' ')
177
+ * + ')';
178
+ * } else {
179
+ * return '(' + head + ' ' + tail.join(' ') + ')';
180
+ * }
181
+ * });
182
+ * @template T
183
+ * @param {(head: Expr, tail: T[]) => T} fun
184
+ * @return {T}
185
+ */
186
+ foldBottomUp<T_1>(fun: (head: Expr, tail: T_1[]) => T_1): T_1;
162
187
  /**
163
188
  * @template T
164
189
  * @param {T} initial
@@ -71,18 +71,4 @@ export function deepFormat(obj: any, options?: object): any;
71
71
  export function declare(expr: Expr, env?: {
72
72
  [s: string]: Named;
73
73
  }): string;
74
- /**
75
- * @experimental
76
- * @desc Fold an application tree bottom to top.
77
- * For each subtree, the function is given the term in the root position and
78
- * a list of the results of folding its arguments.
79
- *
80
- * E,g, fold('x y (z t)', f) results in f(x, [f(y, []), f(z, [f(t, [])])])
81
- *
82
- * @template T
83
- * @param {Expr} expr
84
- * @param {(head: Expr, tail: T[]) => T} fun
85
- * @return {T}
86
- */
87
- export function foldr<T>(expr: Expr, fun: (head: Expr, tail: T[]) => T): T;
88
74
  import { Expr } from "./expr";