Question: How to find the index of a number in an array?

How to find the index of a number in an array?

if a := [11 12 13 14 15];

which function output  number 12's index is 2

 

when write

indexarray := proc(f, target)

N = 7;

for i from 1 to N do

    if f[i] = target then

           return i;

    end if

od;

end proc;

 

error final value in for loop must be numeric or character

Please Wait...