Question: Position in lists and/or Vectors

Consider the list [x,y,z], say. Does there in Maple exist some fundamental function for querying the position in the list of x,y, and z, respectively? I am unable to locate any such. Such a function can, of course, be constructed, an example being the following:

listPos := (l::list) -> table(zip(`=`,l,[$(1..nops(l))])):
pos := listPos([x,y,z]);
pos[x],
pos[y],
pos[z];

But that seems unsatisfactory. The same question concerning Vectors: Consider Vector([x,y,z]), say. Here, the following code, say, will perform the task:

VectorPos := (V::Vector) -> table([map(rhs = lhs,op(2,V))[]]):
pos := VectorPos(Vector([x,y,z]));
pos[x],
pos[y],
pos[z];

PS: Of course, list and Vectors can be converted into one another, so any one of the codes above can in practice be used to perform both tasks.

Please Wait...