# How to generate a list with elements f[i] for a function of several variables f?

I would like to create an array of length n with each element i equal to the function

σEk[j_, k_, n_] :=
Insert[ConstantArray[IdentityMatrix, n - 1], PauliMatrix[j], k ]


evaluated at k=i, i.e.

σEklist[j_, n_] := {σEk[j, 1, n], σEk[j, 2, n], ..., σEk[j, n, n]}


I tried using the Mathematica function for one-variable functions, Array[f,n] = {f[i], ..., f[n]}, using:

σEklist[j_, n_] := Array[σEk, n]


and I also tried to define σEk[j, k, n] as a function of the variable k only within the function σEklist[j_, n_] using Module, i.e.

σEklist[j_, n_] :=
Module[{f[k_] := σEk[j, k, n]}, Array[f, n]]


but in each case the function σEklist[j_, n_] doesn't read the n and j variables in the function σEk[j, k, n] as being its own variables.

Any help or tips would be appreciated, thanks.

• Like this σEklist[j_, n_] := Array[σEk[j,#,n]&, n]? Nov 4 '19 at 18:19

Clear["Global*"]

σEk[j_Integer?(0 <= # <= 4 &), k_Integer?Positive,
n_Integer?Positive] :=
Insert[ConstantArray[IdentityMatrix, n - 1], PauliMatrix[j], k]

σEklist[j_Integer?(0 <= # <= 4 &),
n_Integer?Positive] := σEk[j, #, n] & /@ Range[n]


or

σEklist2[j_Integer?(0 <= # <= 4 &), n_Integer?Positive] :=
Array[σEk[j, #, n] &, n]


σEklist and σEklist2 are equivalent

And @@ (Table[σEklist[j, n] == σEklist2[j, n], {j, 0, 4}, {n, 1,
5}] // Flatten)

(* True *)
`