Question: How to... generate indices of a selected subset of array elements?

Hi, all! Perhaps this is an obvious question for experienced users, but it's given me some trouble as a newbie... many thanks for anyone who can help me with this... I'm trying to find a way to return the indices of a selected subset of an array (or matrix, or whatever, I'm not picky.) Here's a simple example of what I'm talking about. Here's some actual Maple input/output that I ran:
> foo := Array( 1..10 , i -> i ) * 2;

           foo := [ 2 4 6 8 10 12 14 16 18 20 ]

> bar := select( x -> ( x mod 3 = 0 ) , foo );

           bar := [ NULL NULL 6 NULL NULL 12 NULL NULL 18 NULL ]
What I'd really like next is a command that will do:
> baz := FindIndex( x -> ( x mod 3 = 0 ) , foo );

           baz := [ 3 6 9 ]
So I have two questions:
  1. What command performs the "FindIndex" functionality (or something like it)?
  2. Why does 'select' return an array with NULLs in it? Shouldn't those NULLs be dropped? How can I get rid of them?
Thanks again, John
Please Wait...