Skip to content

Commit 3a341d4

Browse files
committed
add derivation from ‘concat’, ‘of’, ‘zero’, and ‘reduce’
1 parent 7dab8da commit 3a341d4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,16 @@ to implement certain methods then derive the remaining methods. Derivations:
886886
}
887887
```
888888

889+
- [`filter`][] may be derived from [`concat`][], [`of`][], [`zero`][], and
890+
[`reduce`][]:
891+
892+
```js
893+
function(pred) {
894+
var F = this.constructor;
895+
return this.reduce((f, x) => pred(x) ? f.concat(F.of(x)) : f, F.zero());
896+
}
897+
```
898+
889899
If a data type provides a method which *could* be derived, its behaviour must
890900
be equivalent to that of the derivation (or derivations).
891901

0 commit comments

Comments
 (0)