3 ms·
Personally I'd avoid currying and go with a function with three params, like: const labelizeElement = ... const labelizeRelation = ... const g
by MaxBarraclough 6y ago
Personally I'd avoid currying and go with a function with three params, like:
const labelizeElement = ...
const labelizeRelation = ...
const groupByLabels = (labelizer, set, element) => ....
const groupByElement = (set, element) => groupByLabels(labelizeElement, set, element);
const groupByRelation = (set, element) => groupByLabels(labelizeRelation, set, element);
This makes it slightly simpler to create a binding function around groupByLabels which fixes, say, the middle argument. I also think that avoiding the chained use of the => operator makes the code more readable to the average JavaScript dev.
C++ has (strange looking) support for the bind pattern in its standard-library now [0], and Python3 has functools.partial but it only supports left-to-right binding [1] (not that there's any particular reason to avoid lambdas).
[0] https://en.cppreference.com/w/cpp/utility/functional/bind https://en.cppreference.com/w/cpp/utility/functional/bind
[1] https://docs.python.org/3/library/functools.html https://docs.python.org/3/library/functools.html