how to make array from elements inside another array

how to make array from elements inside another array ???
1
2
3
4
5
foo is an array that you want to copy data from
bar is an empty array of the same length as foo

for every element in foo
	bar[index] = foo[index]
i want to get specific elements not all elements as foo[2], foo[4] for example put them in bar[0] bar[1]
Conceptually:
 for interesting elements in foo
   bar[ fbmap(index) ] = foo[ index ]

or
 for every element in bar
   bar[ index ] = foo[ bfmap(index) ]

where the functions fbmap() and bfmap() represent mapping from valid indices of one array into valid indices of the other array.
Topic archived. No new replies allowed.