Skip to content

Instantly share code, notes, and snippets.

@jemgold
Created May 10, 2016 13:48
Show Gist options
  • Save jemgold/021d165516739f6df42d966f94f3752c to your computer and use it in GitHub Desktop.
Save jemgold/021d165516739f6df42d966f94f3752c to your computer and use it in GitHub Desktop.
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