3 ms·
Map, reduce, filter, fold, project, transform, group_by, bind, apply - any functional API you care to look is all verbs. Functions do work. That doesn't mean t
by barrkel 6y ago
Map, reduce, filter, fold, project, transform, group_by, bind, apply - any functional API you care to look is all verbs.
Functions do work. That doesn't mean they have to have side-effects; if they're functional, they do work on the input and produce output. Doing is a verb. It's natural.
Using a noun as a function name is at best justified when you have a situation where you want to hide whether data is being calculated on demand, or fetched from some storage or lookup table. Some languages bake this in, in the form of properties - attributes of a structure which look like fields, but are actually functions. Those things have nouns as names.
- augustk 6y agoIt depends on the culture and the programming language. The advantage of using noun phrases for pure functions is that 1. only by reading the name of the function you know it's a pure function 2. a call to a pure function in an expression reads more naturally since operands are values and values are nouns.