# Create an array whose index are given by a list (not necesseraly regularly spaced)

I would like to create an array f containing n indices. The label of those indices is stored in a liste of length n, let's call it "list".

So I would like to have something like :

{f[list[]], f[list[],...}

The point is to affect the f[liste[[i]]] to some values after.

I tried to make a table, but the problem is that the indices cannot be a list from what I have seen (in the sense that they must be regularly spaced).

I also tried to use the array function but I have the same problem, I cannot specify the indices as being a list, it must be a regular spacing.

How can I do it ?

• ... also Table[f[i],{i, list}]? – kglr Jun 24 at 9:51
• List indices start with 1 in Mathematica, so list[] is not valid (it refers to the head, which is List). – Roman Jun 24 at 10:32
• Maybe f /@ list would work. – Roman Jun 24 at 10:33

Use AssociationMap. E.g.,

m = AssociationMap[f, {8, 29, 16}]
m  (* f *)


Given a list of integers,

list = RandomInteger[{1, 10}, 10]
(*    {5, 8, 8, 2, 6, 2, 3, 7, 7, 5}    *)


we can construct the required {f[list[]], f[list[], ...} with

f /@ list
(*    {f, f, f, f, f, f, f, f, f, f}    *)