ClearAll[lenwhile1, lenwhile2]
lenwhile1 = #[[1 + LengthWhile[#[[All, 1]], # <= 0 &]]] &&;
lenwhile2 = #[[1 + LengthWhile[#, #[[1]] <= 0 &]]] &&;
lenwhile1 @ T
{2, 4, 4}
lenwhile1 @ T == lenwhile2 @ T
True
Timings:Timings:
Using aardvark2012's setup with SeedRandom[1]
functions = {firstcase, lenwhile1, lenwhile2, pick, select, selfirst, throwcatch};
where
pick = Pick[#, Sign[#[[All, 1]]], 1][[1]] &;
is suggested by tomd in a comment.
SeedRandom[1]
T1 = RandomInteger[{-5, -1}, {100000, 3}]~Join~{{2, 4, 4}};
T2 = RandomInteger[{-5, 5}, {100000, 3}];
functions = {firstcase, lenwhile1, lenwhile2, pick, select, selfirst, throwcatch};
where tomd's suggestion pick
is
pick = Pick[#, Sign[#[[All, 1]]], 1][[1]] &;
Equal @@ (#[T1]& /@ functions)
True
Equal @@ (#[T2]& /@ functions)
True