# What is the best and most efficient way to curry?

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*)


Next maybe as a Function approach:

(*function approach*)


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:

data1=Table[RepeatedTiming[type1[f]@expr],{1000}][[;;,1]];
data2=Table[RepeatedTiming[type2[f]@expr],{1000}][[;;,1]];
data3=Table[RepeatedTiming[type3[f]@expr],{1000}][[;;,1]];
data4=Table[RepeatedTiming[type4[f]@expr],{1000}][[;;,1]];
data5=Table[RepeatedTiming[type5[f]@expr],{1000}][[;;,1]];


I try to compare the timing:

DistributionChart[{data1,data2},ChartElementFunction->"PointDensity"]
DistributionChart[{data3,data4,data5},ChartElementFunction->"PointDensity"]


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:

DistributionChart[RandomReal[{1*^-7,1*^-6},{3,100}],ChartElementFunction->"PointDensity"]

• +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?" – Ronald Monson May 3 '20 at 0:57