How to display the indexes of a list in a list that are positive values?

jospercomp shared this question 2 years ago
Answered

input={-9,-29,8,17,-192,-44,23,-60,65,32}

index={ 1, 2, 3, 4, 5, 6, 7, 8, 9,10}

output={3,4,7,9,10}

Best Answer
photo

If you want the sublist of index of positive input values then

KeepIf(input(j) > 0, j, index)


You can get ALL indices of positive input values even without using index:

KeepIf(input(j) > 0, j, Sequence(Length(input)))

or

RemoveUndefined(Sequence(If(input(k) > 0, k), k, 1, Length(input)))

Comments (2)

photo
2

If you want the sublist of index of positive input values then

KeepIf(input(j) > 0, j, index)


You can get ALL indices of positive input values even without using index:

KeepIf(input(j) > 0, j, Sequence(Length(input)))

or

RemoveUndefined(Sequence(If(input(k) > 0, k), k, 1, Length(input)))

photo
1

It is get ALL indices of positive input values even without using index.

photo
© 2023 International GeoGebra Institute