Skip to content

Commit 67c7152

Browse files
author
jethro larson
committed
Added definition for predicate.
1 parent 13de2a5 commit 67c7152

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Where applicable, this document uses terms defined in the [Fantasy Land spec](ht
1717
* [Side effects](#side-effects)
1818
* [Idempotent](#idempotent)
1919
* [Point-Free Style](#point-free-style)
20+
* [Predicate](#predicate)
2021
* [Contracts](#contracts)
2122
* [Guarded Functions](#guarded-functions)
2223
* [Categories](#categories)
@@ -197,7 +198,14 @@ let incrementAll2 = map(add(1));
197198

198199
Points-free function definitions look just like normal assignments without `function` or `=>`.
199200

201+
## Predicate
202+
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.
200203

204+
```js
205+
const predicate = (a) => a > 2;
206+
207+
[1, 2, 3, 4].filter(predicate); // [3, 4]
208+
```
201209

202210
## Contracts
203211

0 commit comments

Comments
 (0)