Suppose I have a function with a signature like g[expr, _?(f), {1}, Heads -> False] and I want to access it as an operator by giving the first argument last. I see there are various ways of doing this:

First as explicit Curry form:

(*curry approach*)
type2=  f\[Function]CurryApplied[g,{4,1,2,3}][_?(f),{1},Heads->False];

Next maybe as a Function approach:

(*function approach*)
type4=  f\[Function]g[#,_?(f),{1},Heads->False]&;

Also since only two level of calls are required, as a SubValue:

(*subvalue approach*)

Now my question is what is the "proper" and most efficient way to do this kind of call. I try timing the calls as follows:


I try to compare the timing:


It appears SubValue way of calling is the fastest. The new way of Curry is slowest. Can someone explain why there are differences in timing?

Also, I don't know why I get a Pink Box when using "PointDensity". Am I using "PointDensity" incorrectly? (I am on 12.1)

By the way, the Pink Box appears to be a bug and is reproducible by the following command:

  • 4
    $\begingroup$ +1 Good question. For completeness you might consider adding OperatorApplied into the mix since it is apparently more closely associated with applications. Also, "proper" is going to be subjective/context-dependent although you seem to be mostly conflating it with efficiency. If that is the main goal then including "proper" might confuse the issue; if the broader "proper" is intended (which I would be interested in) then maybe consider broadening the question to "What is the best way to Curry?" $\endgroup$ – Ronald Monson May 3 '20 at 0:57

Your Answer

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

Browse other questions tagged or ask your own question.