There is 4 lists, 3 of them are at same length (l0, l1 and l3).
l0={2,3,4,2,5};
l1={{1,2},{2,4},{3,1},{4,3},{5,1}};
l2={{1,2},{1,3},{2,1},{3,1},{4,5},{5,4}};
l3={0,0,0,0,0};
Each member of l0 should be comparison with second element of corresponding member of l1, if it was greater we call them Beep members.(here third and fifth member of l0), then from l2 we choose members that have equal value at first element with Beep (first element) and call them Ops. At last add one to each element of l3 at position Ops[[2]] .
here: Beep: {3,1} and {5,1}, Ops: {3,1} and {5,4} and finally l3={1,0,0,1,0}.
I write a function that do this, Is it best way for doing this?
Func[l0_] :=
Module[{l3 = ConstantArray[0, n]},
MapThread[
If[#1 > #2[[2]], ++l3[[
Cases[l2, {x_, y_} /; x == #2[[1]] :> y]]]] &, {l0, l1}];
];
How to Compile it?
l3[[#]] ++ & /@ Last /@ Cases[ l2, {Alternatives @@ (First /@ Pick[l1, Thread[l0 > Last /@ l1]]), _}]– Dr. belisarius Jan 16 '16 at 05:53l1andl2always2? – xzczd Jan 16 '16 at 07:09l1is their position. – jack cilba Jan 16 '16 at 08:09