Module rust2fun::combinator

source ·
Expand description

Combinators

A combinator is a higher-order function that uses only function application and earlier defined combinators to define a result from its arguments.

Functions

  • The apply function apply(f, x) = f(x) also known as A (Apply) combinator. It is the same as function application.
  • The application function apply_to(x, f) = f(x) also known as T (Thrush) combinator.
  • Provides a means of passing an accumulating function and two branching functions. A value can be applied to the resulting function which will then be applied to each branching function, the results of which will be applied to the accumulating function.
  • This function also known as Y combinator allows for recursive functions to be defined in a more natural way. It takes a function that takes a function and a value, and returns a value. The function is then applied to itself, and the value is returned.
  • The identity function id(x) = x also known as I (Idiot) combinator.
  • This function allows for conditionals in composition chains. Unlike converge, which branches and merges, if_else chooses which function to run based on the predicate, and the other function is ignored.
  • The no operation function.
  • The no operation function of 1 argument.
  • The no operation function of 2 arguments.
  • The no operation function of 3 arguments.
  • The no operation function of 4 arguments.
  • The no operation function of 5 arguments.
  • The no operation function of 6 arguments.
  • The no operation function of 7 arguments.
  • The no operation function of 8 arguments.
  • The no operation function of 9 arguments.
  • The no operation function of 10 arguments.
  • The no operation function of 11 arguments.
  • The no operation function of 12 arguments.
  • This function, also called the Psi combinator, allows you to call a function on transformations of values. It can be considered the sister of converge. Where converge takes one argument and maps it through two unary functions, merging the resulting values with a binary function, psi takes two arguments and runs them each through the same unary function before merging them with the given binary function.
  • This substitution function, also known as S (Starling) combinator, is used when you have a binary function and you can supply the first argument and can use that value to create the second argument.
  • Create a tuple of 2 elements.
  • Create a tuple of 3 elements.
  • Create a tuple of 4 elements.
  • Create a tuple of 5 elements.
  • Create a tuple of 6 elements.
  • Create a tuple of 7 elements.
  • Create a tuple of 8 elements.
  • Create a tuple of 9 elements.
  • Create a tuple of 10 elements.
  • Create a tuple of 11 elements.
  • Create a tuple of 12 elements.