mirror of
https://github.com/rjNemo/functional-programming-jargon
synced 2026-06-10 12:36:48 +00:00
Merge pull request #54 from jethrolarson/pred
Added definition for predicate.
This commit is contained in:
commit
98fbaff76b
1 changed files with 8 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ Where applicable, this document uses terms defined in the [Fantasy Land spec](ht
|
||||||
* [Side effects](#side-effects)
|
* [Side effects](#side-effects)
|
||||||
* [Idempotent](#idempotent)
|
* [Idempotent](#idempotent)
|
||||||
* [Point-Free Style](#point-free-style)
|
* [Point-Free Style](#point-free-style)
|
||||||
|
* [Predicate](#predicate)
|
||||||
* [Contracts](#contracts)
|
* [Contracts](#contracts)
|
||||||
* [Guarded Functions](#guarded-functions)
|
* [Guarded Functions](#guarded-functions)
|
||||||
* [Categories](#categories)
|
* [Categories](#categories)
|
||||||
|
|
@ -197,7 +198,14 @@ let incrementAll2 = map(add(1));
|
||||||
|
|
||||||
Points-free function definitions look just like normal assignments without `function` or `=>`.
|
Points-free function definitions look just like normal assignments without `function` or `=>`.
|
||||||
|
|
||||||
|
## Predicate
|
||||||
|
A predicate is a function that returns true or false for a given value. A common use of a predicate is as the callback for array filter.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const predicate = (a) => a > 2;
|
||||||
|
|
||||||
|
[1, 2, 3, 4].filter(predicate); // [3, 4]
|
||||||
|
```
|
||||||
|
|
||||||
## Contracts
|
## Contracts
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue