Skip to content

Commit

Permalink
added definition for functional combinator hemanth#126
Browse files Browse the repository at this point in the history
  • Loading branch information
jethrolarson committed Jul 29, 2022
1 parent 6797f89 commit ddf6a95
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ __Table of Contents__
* [Equational Reasoning](#equational-reasoning)
* [Lambda](#lambda)
* [Lambda Calculus](#lambda-calculus)
* [Functional Combinator](#functional-combinator)
* [Lazy evaluation](#lazy-evaluation)
* [Monoid](#monoid)
* [Monad](#monad)
Expand Down Expand Up @@ -579,6 +580,24 @@ const add1 = (a) => a + 1
## Lambda Calculus
A branch of mathematics that uses functions to create a [universal model of computation](https://en.wikipedia.org/wiki/Lambda_calculus).

## Functional Combinator
A higher-order function, usually curried, which returns a new function changed in some way. Functional combinators are often used in [Point-Free Style](#point-free-style) to write especially terse programs.

```js
// The "C" combinator takes a curried two-argument function and returns one which calls the original function with the arguments reversed.
const C = (f) => (a) => (b) => f(b)(a)

const divide = (a) => (b) => a / b

const divideBy = C(divide)

const divBy10 = divideBy(10)

divBy10(30) // => 3
```

See also [List of Functional Combinators in JavaScript](https://gist.github.com/Avaq/1f0636ec5c8d6aed2e45) which includes links to more references.

## Lazy evaluation

Lazy evaluation is a call-by-need evaluation mechanism that delays the evaluation of an expression until its value is needed. In functional languages, this allows for structures like infinite lists, which would not normally be available in an imperative language where the sequencing of commands is significant.
Expand Down

0 comments on commit ddf6a95

Please sign in to comment.