These are chat archives for ramda/ramda

12th
Sep 2015
Tamas
@bling5630
Sep 12 2015 09:07

Hi guys,

Even though I could split this function two shorter separated parts, and they are working as well, but I would like to implement a point-free way, do you have any idea about it, thanks, Tamas

input:

[ 
  'apple',
  'apple',
  'pear',
  'apple',
  'pear',
  'cherry'
   ]

function calculateByFrequency(content) {
    return _.reduce(content, function(countMap, word) {
        countMap[word] = ++countMap[word] || 1;
        return countMap;
    }, {});
}

desired output:

{ apple: 3, pear: 2, cherry: 1 }
Raine Virta
@raine
Sep 12 2015 09:10
countBy is the answer
R.countBy(R.identity, input);
Tamas
@bling5630
Sep 12 2015 09:22
This message was deleted
oh no, that's all, thanks @raine :)
Tobias Pflug
@gilligan
Sep 12 2015 09:43
sigh, still totally stuck with jsverify
Raine Virta
@raine
Sep 12 2015 11:56
objFromKeys proved itself useful again
Hardy Jones
@joneshf
Sep 12 2015 13:52
@gilligan what's up?