Created
August 21, 2016 03:56
-
-
Save ipassynk/b81e4c5106344a5f86d2eff99a6755ab 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
let words = "aaa ggg aaa ggg aaa ffff aaa ggg aaa ggg aaa fff rrrr aaa"; | |
let y = _.compose( | |
_.get('word'), | |
_.head, | |
_.orderBy('count', 'desc'), | |
_.map(p=>({word:p[0], count:p[1]})), | |
_.toPairs, | |
_.reduce((acc, next) => { | |
acc[next] = (acc[next] && acc[next]+1) || 1; | |
return acc; | |
}, {}), | |
_.split(' ') | |
)(words); | |
console.log(y); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment