Im trying to further my understanding of mathematica coding and came up across this question. What is the main difference between Cases
and Select
?
data = Table[{RandomReal[{-10, 10}], RandomReal[{-10, 10}], RandomReal[{-10, 10}]}, 10^4];
Cases[data, {a_, b_, c_} :> {a, b} /; c > 0]
Select[data, #[[3]] > 0 &][[All, ;; 2]]
Both these approaches give the same result, Im just curious about the benefits of each. When is Select
superior to Cases
and vice versa.
Pick[data, UnitStep[data[[All, 3]]], 1]
for speed? $\endgroup$