19
$\begingroup$

Perhaps this is just one of those Mathematica curiosities, but I'd like to know why by default

OperatorApplied[f][x][y] === f[y,x]

versus the more usual way one would expect it to work,

OperatorApplied[f,2][x][y] === f[x,y]
$\endgroup$
  • 1
    $\begingroup$ Presumably to be consistent with the behavior of the function to be phased out, i.e., Curry. OperatorApplied[f][x][y] === Curry[f][x][y] and OperatorApplied[f,2][x][y] === Curry[f,2][x][y] $\endgroup$ – Bob Hanlon Mar 20 at 15:41
  • $\begingroup$ Just for the sake of completeness: OperatorApplied[f, 2][x][y] === CurryApplied[f, 2][x][y] $\endgroup$ – murray Mar 20 at 21:40
12
$\begingroup$

It comes down to being consistent with the convention/idiom/pattern of WL functions typically having as a first argument an object to be operated on with typically the second argument doing the operating. Operator forms, in contrast, most naturally take as a first argument the thing doing the operating which is therefore most commonly the original function's second argument - hence the reversal.

Well in some ways this question doesn't have a precise answer since you would need to get into the minds of WRI developers (which I don't think is a reason to close--the question's takeaway is useful IMO) but some evidence for assessing "typically" ...

enter image description here

While common it is not absolute e.g. Replace and TuringMachine have operator forms with first argument type (rules,rule) that correspond to different positions (second, first) in the original function.

| improve this answer | |
$\endgroup$
  • 2
    $\begingroup$ Well, you beat me to the answer, but this is right. It's called "OperatorApplied" to suggest it behaves like an "operator form", which mostly take the 2nd argument. It's dfiferent from CurryApplied which is normally ordered in its 1-arg form. $\endgroup$ – Itai Seggev Mar 21 at 7:01
  • 1
    $\begingroup$ Ok, good - thanks for confirming. At a deeper level, OperatorApplied seems to be the more "practical wing" of CurryApplied which seems to be being reserved for more fundamental work associated with combinators etc. On the other hand, the only difference between the two functions seems to be in their respective operator forms? (b.t.w. the naming with trailing Applied's is v.nice - captures intuitively the moment of resolving). $\endgroup$ – Ronald Monson Mar 22 at 3:02

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.