Options
All
  • Public
  • Public/Protected
  • All
Menu

Module function/converge

Index

References

Renames and re-exports converge

Functions

  • Accepts a converging function and a list of branching functions and returns a new function. The arity of the new function is the same as the arity of the longest branching function. When invoked, this new function is applied to some arguments, and each branching function is applied to those same arguments. The results of each branching function are passed as arguments to the converging function to produce the return value.

    sig

    ((x1, x2, ...) -> z) -> [((a, b, ...) -> x1), ((a, b, ...) -> x2), ...] -> (a -> b -> ... -> z)

    example
     const average = converge(divide, [sum, length])
    average([1, 2, 3, 4, 5, 6, 7]) //=> 4

    const strangeConcat = converge(concat, [toUpper, toLower])
    strangeConcat("Yodel") //=> "YODELyodel"
    symb

    converge(f, [g, h])(a, b) = f(g(a, b), h(a, b))

    Parameters

    Returns ConvergeArgFn

    A new function.

  • Accepts a converging function and a list of branching functions and returns a new function. The arity of the new function is the same as the arity of the longest branching function. When invoked, this new function is applied to some arguments, and each branching function is applied to those same arguments. The results of each branching function are passed as arguments to the converging function to produce the return value.

    sig

    ((x1, x2, ...) -> z) -> [((a, b, ...) -> x1), ((a, b, ...) -> x2), ...] -> (a -> b -> ... -> z)

    example
     const average = converge(divide, [sum, length])
    average([1, 2, 3, 4, 5, 6, 7]) //=> 4

    const strangeConcat = converge(concat, [toUpper, toLower])
    strangeConcat("Yodel") //=> "YODELyodel"
    symb

    converge(f, [g, h])(a, b) = f(g(a, b), h(a, b))

    Parameters

    • after: ConvergeAfterFn

      A function. after will be invoked with the return values of fn1 and fn2 as its arguments.

    Returns (fns: ConvergeArgFn[]) => ConvergeArgFn

    A new function.

Generated using TypeDoc