I’m looking for help to extracting the first and last value of a given list.
I have a binary parameter L(p,i) which will be given varios list of data.
For example:
List p=1:
i=1 → 0
i=2 → 1
i=3 → 1
i=4 → 0
List p=2:
i=1 → 1
i=2 → 0
i=3 → 1
i=4 → 1
I’m looking for a command which will extract the first i which is set to 1 on a given list. In this Example for the list p=1 it would be i=2 and for the list p=2 it would be i=1.
I’m also looking for a command which will extract the last i which is set to 1 on a given list. In this example for the list p=1 it would be i=3 and for the list p=2 it would be i=4.
I tried the “First” and “Last” command which always lead to using i=1 (for the command “First”) even though in the example p=1 the value of i=1 is 0 and not 1.
Any help would be appreciated.