From: ngry on
Hi,
Task: Compute "histogram feature" for certain object properties.
Object is represented by 2D point set. Histogram position(offset) and
integral object feature to compute is formalized separately.
My solution (mathematica code):

(* offset computation, single point update *)
PointUpdateResult[res_, x_, y_, Order_] := Block[ {offset = MyOffset[x, y, Order] },
++res[[offset,1]]; (* count *)
res[[offset,2]] += Sqrt[x^2 + y^2]; (* "integral feature" *)
];
SetAttributes[PointUpdateResult, {HoldFirst}];

(* Per-point iteration *)
UpdateResult[res_, x_, y_, Order_, r_] := For[cr=0, cr<r, ++cr;
PointUpdateResult[res, x+cr, y, Order] ];
SetAttributes[UpdateResult, {HoldFirst}];

(* object processing *)
SectorFeatures[x_, Order_]:= Block[ { params=Runs[x], second_params Mec[x], resTable[{0,0},Order] (* Histogram "memory allocation" *)}, UpdateResult[res,second_params,Order,#] & /@ params;
res // MatrixForm
];

As it can be seen, I have to simulate "pass by reference" for cyclic
accumulation of needed feature. Is there any hints to simplify
iteration for computing such histograms?
Or, something to simulate object identification by its key (I've used
unique offset in histogram)?