UNPKG

lambda-calculus-with-js

Version:

Using JS' anonymous functions to perform lambda calculus

82 lines (81 loc) 2.97 kB
export interface Lambda { (x: Lambda): Lambda; testTag?: Tested; recursing?: () => Lambda; } type StrArr = string | StrArr[]; export declare abstract class Tested { abstract rebuild(this: this, ids?: Record<number, Lambda>): Lambda; abstract toJs(this: this): string; abstract toLambda(this: this, std: boolean): string; abstract kfcify(this: this, num: boolean, indenter: Indenter, table: Record<number, number>, depth: number): StrArr; toKfc(this: this, num: boolean): string; } interface Indenter { (context: string): string; next(): Indenter; } export declare class TestedFunc extends Tested { readonly arg: TestedArg; readonly value: Tested; constructor(arg: TestedArg, value: Tested); rebuild(this: this, ids?: Record<number, Lambda>): Lambda; toJs(this: this): string; toLambda(this: this, std: boolean): string; kfcify(this: this, num: boolean, indenter: Indenter, table: Record<number, number>, depth: number): StrArr; } export declare class TestedCall extends Tested { readonly caller: Tested; readonly arg: Tested; constructor(caller: Tested, arg: Tested); rebuild(ids?: Record<number, Lambda>): Lambda; toJs(this: this): string; toLambda(this: this, std: boolean): string; kfcify(this: this, num: boolean, indenter?: Indenter, table?: Record<number, number>, depth?: number): StrArr; } export declare class TestedArg extends Tested { readonly id: number; constructor(id: number); rebuild(ids?: Record<number, Lambda>): Lambda; toJs(this: this): string; toLambda(this: this, _: boolean): string; kfcify(this: this, num: boolean, indenter?: Indenter, table?: Record<number, number>, depth?: number): StrArr; } export declare class TestedConst extends Tested { readonly inner: number; constructor(inner: number); rebuild(_?: Record<number, Lambda>): Lambda; toJs(this: this): string; toLambda(this: this, _: boolean): string; kfcify(this: this, num: boolean, indenter?: Indenter): StrArr; } /**getLambda */ export declare function gl(lambda: Lambda): Lambda; export declare function test(lambda: Lambda, argTotal?: { id: number; }): Tested; export declare enum Log { /**普通 Lambda 表达式 */ Std = 0, /**JavaScript 代码 */ Js = 1, /**大部分 Lambda 演算网站可以正确识别的形式 */ Exable = 2, /**KFC 语言 */ Kfc = 3, /**使用数字的易懂的 KFC 语言 */ KfcNum = 4 } export declare function log(n: Lambda, level?: Log): void; /**Y Combinator */ export declare const yC: Lambda; export declare const recursionConfig: { /**递归次数限制,超过就被认为是死循环 */ max: number; /**实验性,如果为 true ,递归函数的最大参数数量不受栈空间影响 */ boldlyReceiving: boolean; }; export declare function solve(n: Lambda): Lambda; /**free identifier */ export declare const fI: Lambda[]; export {};