-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
832dc8d
commit 59766a3
Showing
8 changed files
with
103 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
const {filter} = require('..'); | ||
|
||
/** | ||
### Filterable | ||
1. `v.filter(x => p(x) && q(x))` is equivalent to `v.filter(p).filter(q)` (distributivity) | ||
2. `v.filter(x => true)` is equivalent to `v` (identity) | ||
3. `v.filter(x => false)` is equivalent to `w.filter(x => false)` | ||
if `v` and `w` are values of the same Filterable (annihilation) | ||
**/ | ||
|
||
const distributivity = eq => v => p => q => { | ||
const a = v[filter](x => p(x) && q(x)); | ||
const b = v[filter](p)[filter](q); | ||
return eq(a, b); | ||
}; | ||
|
||
const identity = eq => v => { | ||
const a = v[filter](x => true); | ||
const b = v; | ||
return eq(a, b); | ||
}; | ||
|
||
const annihilation = eq => v => w => { | ||
const a = v[filter](x => false); | ||
const b = w[filter](x => false); | ||
return eq(a, b); | ||
}; | ||
|
||
module.exports = {distributivity, identity, annihilation}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters