I have a list of numbers and I want to find the last element of it that satisfies certain condition. In this case, the condition is that the number equals 1. I need exactly the position of that element but I don't know how to do it.
I think that this is very basic but I don't know too much about Mathematica. I read the solution given here and tried with
Select[x[i], #=1&]
But it did not work. Anyone knows something?
Last[Position[x,1]]
should suffice (I assume you're asking about Mathematica here)... $\endgroup$Max@Position[x, _?(# == 1 &)]
$\endgroup$Equal
(==
), notSet
(=
). (2) It's good to include any error messages you get with the question, usually. $\endgroup$