The way I read this code makes me think that the elements [2, 3] are both even. To sanity check, I modified this to print to the REPL to try to understand what was going on better and that output makes sense to me:
So many other functions in Base use a similar pattern, where a function as a first argument serves to transform the data before the core functionality of the function is applied.
It’s really nice when used with the do syntax, but can be confusing at first, in cases such as this one. Overall I think it’s a nice use of multiple dispatch though, and easy to make sense of and remember once you’ve grasped the general idea. Giving only this one a map... prefix would be inconsistent and ultimately more confusing.
That’s true, but there are differences in how exactly the inner function values are used.
Many functions just apply it first, equivalent to func(f, A) == func(map(f, A)): eg maximum and findmax. Others do different things that cannot be expressed with a separate map: eg argmax and unique. I can easily understand how this could lead to confusion.