3
$\begingroup$

I keep being uncertain of the correct order of [function,expr] arguments to functions such as Select, Pick, Cases, Position, etc., because I'm used to the [f, expr] order from the Map family of functions.

  1. Is there a good rule of thumb to remember which order should be used where?
  2. More importantly, is there a good reason that the Map family has it opposite to the rest? Incidentally this may help with 1 as well.
$\endgroup$
2
$\begingroup$

I think that Map is the exception. I would read

 Map[f,list]

as "map f over list". Same for

 Apply[f  x]

meaning "apply f to `x".

In contrast, I would read

Select[list,list]

as "select from list by (selector) f. The same applies to Pick. But have to idea for Cases and Position, basically because they are no verbs.

| improve this answer | |
$\endgroup$
  • $\begingroup$ I understand the structure of the Map sentence (and actually the Map family is the one where I don't confuse the order). However, I'm unclear on why "Select from list by f" is more natural than "Select by f from list. Perhaps SQL SELECT statement should be the guide here, since the WHERE clause comes after the data clause there as well. $\endgroup$ – Shwouchk Nov 9 '19 at 2:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.