Last active
November 4, 2019 22:11
-
-
Save jasonknight/200a232dffc8875427d90a09d3b79906 to your computer and use it in GitHub Desktop.
Revisions
-
jasonknight revised this gist
Nov 4, 2019 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -39,13 +39,13 @@ function filter(fn) { return list.filter(fn); } } function onlyAdmins() { return filter(propertyp('admin')('role')); } function onlyEmails() { return map(property('email')); } var getAdminEmails = compose( onlyEmails(), onlyAdmins()); var admin_emails = getAdminEmails(users); -
jasonknight revised this gist
Nov 4, 2019 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -42,7 +42,10 @@ function filter(fn) { function onlyadmins() { return filter(propertyp('admin')('role')); } function onlyemails() { return map(property('email')); } var getAdminEmails = compose( onlyemails(), onlyadmins()); var admin_emails = getAdminEmails(users); -
jasonknight created this gist
Nov 4, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ var users = [ { role: 'admin', email: '[email protected]' }, { role: 'user', email: '[email protected]' }, { role: 'admin', email: '[email protected]' }, ]; function compose(f,g) { return function (x) { return f(g(x)); }; } function property(p) { return function (x) { return x[p]; }; } function propertyp(v) { return function (p) { return function (o) { return property(p)(o) == v; }; }; } function map(fn) { return function (list) { return list.map(fn); }; } function filter(fn) { return function(list) { return list.filter(fn); } } function onlyadmins() { return filter(propertyp('admin')('role')); } var getAdminEmails = compose( map(property('email')), filter(propertyp('admin')('role'))); var admin_emails = getAdminEmails(users);