# Module: core.lambda¶

Stability: 3 - Stable https://github.com/folktale/core.lambda/issues 1.0.0 https://github.com/folktale/core.lambda Portable core.lambda

Core combinators and higher-order functions.

Require the core.lambda package, after installing it:

var lambda = require('core.lambda')


## Why?¶

Functional programming places heavy emphasis in composition (specially function composition), but JavaScript lacks built-in functionality for composing and transforming functions in order to compose them. core.lambda fills this gap by providing tools for composing functions, altering the shape of a function in order to compose them in different ways, and currying/uncurrying.

## Uncategorised¶

### identity()¶

core.lambda.identity(a)
Returns: The argument it’s given.
α → α


The identity combinator. Always returns the argument it’s given.

### constant()¶

core.lambda.constant(a, b)
Returns: The first argument it’s given.
α → β → α


The constant combinator. Always returns the first argument it’s given.

### apply()¶

core.lambda.apply(f, a)
Returns: The result of applying f to a.
(α → β) → α → β


Applies a function to an argument.

### flip()¶

core.lambda.flip(f)
Returns: The function f with parameters inverted.
(α → β → γ) → (β → α → γ)


Inverts the order of the parameters of a binary function.

### compose()¶

core.lambda.compose(f, g)
Returns: A composition of f and g.
(β → γ) → (α → β) → (α → γ)


Composes two functions together.

### curry()¶

core.lambda.curry(n, f)
Returns: A curried version of f, up to n arguments.
ₙ:Number → (α₁, α₂, ..., αₙ → β) → (α₁ → α₂ → ... → αₙ → β)


Transforms any function on tuples into a curried function.

core.lambda.spread(f, xs)
Returns: The result of applying the function f to arguments xs.
(α₁ → α₂ → ... → αₙ → β) → (#[α₁, α₂, ..., αₙ] → β)


Applies a list of arguments to a curried function.

### uncurry()¶

core.lambda.uncurry(f)
Returns: A function on tuples.
(α₁ → α₂ → ... → αₙ → β) → (α₁, α₂, ..., αₙ → β)


Transforms a curried function into a function on tuples.

### upon()¶

core.lambda.upon(f, g)
Returns: A binary function f with arguments transformed by g.
(β → β → γ) → (α → β) → (α → α → γ)


Applies an unary function to both arguments of a binary function.