Say I have a list x={2,4,6,8,10} and I want to find out the positions of the elements that are greater than 7.
Select[x, #>7&] gives the elements themselves, and Position[x,8] gives the position of the elements satisfying one of the possible criteria, but what I am looking for would be a mix of the two returning {4,5}.
Any suggestions?
Pickto enhance performance:x = {2, 4, 6, 8, 10}; Pick[Range[Length[x]], Sign[x - 6], 1]. – Sasha Jan 18 '12 at 20:46PatternTestrather thanCondition. Are any performance differences or is it just what people are used to? – Mike Honeychurch Jan 18 '12 at 22:15Conditionfor ease of naming elements to work with them. – Brett Champion Jan 19 '12 at 01:05{2, 4, 6, 8, 10} // Position[_?(GreaterThan[7])]– AsukaMinato Oct 13 '23 at 13:02