Created
May 10, 2016 13:48
-
-
Save jemgold/021d165516739f6df42d966f94f3752c 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
import { compose, countBy, divide, filter, groupBy, head, last, toLower, map, prop, sum, values } from 'ramda'; | |
const sumValues = compose(sum, values); | |
export function countByFrom(input) { | |
return compose( | |
map(countBy(last)), | |
groupBy(head), | |
filter((x) => { | |
return x.length > 1; | |
}) | |
)(input); | |
} | |
export const probablize = map((row) => { | |
const total = sumValues(row); | |
return map((val) => { | |
return divide(val, total); | |
}, row); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment