import { Stream } from "./Stream"; import { Cell } from "./Cell"; import { Source } from "./Vertex"; export class Lambda1 { constructor(f : (a : A) => B, deps : Array|Cell>) { this.f = f; this.deps = deps; } f : (a : A) => B; deps : Array|Cell>; } export function lambda1(f : (a : A) => B, deps : Array|Cell>) : Lambda1 { return new Lambda1(f, deps); } export function Lambda1_deps(f : ((a : A) => B) | Lambda1) : Array|Cell> { if (f instanceof Lambda1) return f.deps; else return []; } export function Lambda1_toFunction(f : ((a : A) => B) | Lambda1) : (a : A) => B { if (f instanceof Lambda1) return f.f; else return <(a : A) => B>f; } export class Lambda2 { constructor(f : (a : A, b : B) => C, deps : Array|Cell>) { this.f = f; this.deps = deps; } f : (a : A, b : B) => C; deps : Array|Cell>; } export function lambda2(f : (a : A, b : B) => C, deps : Array|Cell>) : Lambda2 { return new Lambda2(f, deps); } export function Lambda2_deps(f : ((a : A, b : B) => C) | Lambda2) : Array|Cell> { if (f instanceof Lambda2) return f.deps; else return []; } export function Lambda2_toFunction(f : ((a : A, b : B) => C) | Lambda2) : (a : A, b : B) => C { if (f instanceof Lambda2) return f.f; else return <(a : A, b : B) => C>f; } export class Lambda3 { constructor(f : (a : A, b : B, c : C) => D, deps : Array|Cell>) { this.f = f; this.deps = deps; } f : (a : A, b : B, c : C) => D; deps : Array|Cell>; } export function lambda3(f : (a : A, b : B, c : C) => D, deps : Array|Cell>) : Lambda3 { return new Lambda3(f, deps); } export function Lambda3_deps(f : ((a : A, b : B, c : C) => D) | Lambda3) : Array|Cell> { if (f instanceof Lambda3) return f.deps; else return []; } export function Lambda3_toFunction(f : ((a : A, b : B, c : C) => D) | Lambda3) : (a : A, b : B, c : C) => D { if (f instanceof Lambda3) return f.f; else return <(a : A, b : B, c : C) => D>f; } export class Lambda4 { constructor(f : (a : A, b : B, c : C, d : D) => E, deps : Array|Cell>) { this.f = f; this.deps = deps; } f : (a : A, b : B, c : C, d : D) => E; deps : Array|Cell>; } export function lambda4(f : (a : A, b : B, c : C, d : D) => E, deps : Array|Cell>) : Lambda4 { return new Lambda4(f, deps); } export function Lambda4_deps(f : ((a : A, b : B, c : C, d : D) => E) | Lambda4) : Array|Cell> { if (f instanceof Lambda4) return f.deps; else return []; } export function Lambda4_toFunction(f : ((a : A, b : B, c : C, d : D) => E) | Lambda4) : (a : A, b : B, c : C, d : D) => E { if (f instanceof Lambda4) return f.f; else return <(a : A, b : B, c : C, d : D) => E>f; } export class Lambda5 { constructor(f : (a : A, b : B, c : C, d : D, e : E) => F, deps : Array|Cell>) { this.f = f; this.deps = deps; } f : (a : A, b : B, c : C, d : D, e : E) => F; deps : Array|Cell>; } export function lambda5(f : (a : A, b : B, c : C, d : D, e : E) => F, deps : Array|Cell>) : Lambda5 { return new Lambda5(f, deps); } export function Lambda5_deps(f : ((a : A, b : B, c : C, d : D, e : E) => F) | Lambda5) : Array|Cell> { if (f instanceof Lambda5) return f.deps; else return []; } export function Lambda5_toFunction(f : ((a : A, b : B, c : C, d : D, e : E) => F) | Lambda5) : (a : A, b : B, c : C, d : D, e : E) => F { if (f instanceof Lambda5) return f.f; else return <(a : A, b : B, c : C, d : D, e : E) => F>f; } export class Lambda6 { constructor(f : (a : A, b : B, c : C, d : D, e : E, f : F) => G, deps : Array|Cell>) { this.f = f; this.deps = deps; } f : (a : A, b : B, c : C, d : D, e : E, f : F) => G; deps : Array|Cell>; } export function lambda6(f : (a : A, b : B, c : C, d : D, e : E, f : F) => G, deps : Array|Cell>) : Lambda6 { return new Lambda6(f, deps); } export function Lambda6_deps(f : ((a : A, b : B, c : C, d : D, e : E, f : F) => G) | Lambda6) : Array|Cell> { if (f instanceof Lambda6) return f.deps; else return []; } export function Lambda6_toFunction(f : ((a : A, b : B, c : C, d : D, e : E, f : F) => G) | Lambda6) : (a : A, b : B, c : C, d : D, e : E, f : F) => G { if (f instanceof Lambda6) return f.f; else return <(a : A, b : B, c : C, d : D, e : E, f : F) => G>f; } export function toSources(deps : Array|Cell>) : Source[] { const ss : Source[] = []; for (let i = 0; i < deps.length; i++) { const dep = deps[i]; ss.push(new Source(dep.getVertex__(), null)); } return ss; }