Counter for each element of array [1,2,1,2,4,2,1] //-> [[1, 1], [2, 1], [1, 2], [2, 2], [4, 1], [2, 3], [1, 3]]
const frequency = o(nth(1), mapAccum((acc, val) => {
const getIncreasedVal = o(inc, propOr(0, val))
const getAccumPair = juxt([assoc(val, __, acc), pair(val)]);
return o(getAccumPair, getIncreasedVal)(acc)
}, {}
));
frequency([1,2,1,2,4,2,1]); //=> [[1, 1], [2, 1], [1, 2], [2, 2], [4, 1], [2, 3], [1, 3]]