Last active
November 10, 2017 16:55
-
-
Save rjhilgefort/bbd55293bb7a8d6c111f8f3515dc4b58 to your computer and use it in GitHub Desktop.
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
// NOTE: Ramda repl | |
console.clear() | |
const foo = [ | |
{ id: 'one' }, | |
{ id: 'two' }, | |
{ id: 'three' }, | |
] | |
const keyBy_point = getter => data => | |
reduce( | |
(acc, val) => assoc(getter(val), val, acc), | |
{}, | |
)(data) | |
const keyBy_pointFree = getter => | |
reduce( | |
pipe( | |
unapply(identity), | |
converge(append, [last, identity]), | |
reverse, | |
apply(useWith(assoc, [getter, identity, identity])), | |
), | |
{}, | |
) | |
console.log( | |
keyBy_point(prop('id'))(foo), | |
keyBy_pointFree(prop('id'))(foo) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment