@thi.ng/pointfree
Version:
Pointfree functional composition / Forth style stack execution engine
32 lines • 1.08 kB
TypeScript
import type { Fn, Fn2 } from "@thi.ng/api";
import type { StackContext } from "./api.js";
/**
* Higher order word. Replaces TOS of d-stack with result of given op.
*
* Stack effect: `( x -- y )`
*
* @param op -
*/
export declare const defOp1: (op: Fn<any, any>) => (ctx: StackContext) => StackContext;
/**
* Higher order word. Takes 2 values from d-stack and writes back result
* from given op. The arg order is (TOS, TOS-1)
*
* Stack effect: `( a b -- c )`
*
* @param op -
*/
export declare const defOp2: (op: Fn2<any, any, any>) => (ctx: StackContext) => StackContext;
/**
* Similar to {@link map2}, but for array operators. Either `a` or `b` can be a
* non-array value, but not both. Creates new array of result values.
* The result will have the same length as the shortest arg (if `a` and
* `b` have different lengths).
*
* - `( a b -- a )`, if `a` is an array
* - `( a b -- b )`, if `a` is not an array
*
* @param f -
*/
export declare const defOp2v: (f: Fn2<any, any, any>) => (ctx: StackContext) => StackContext;
//# sourceMappingURL=ops.d.ts.map