1
$\begingroup$

This question already has an answer here:

How to make Array as in following example but without list variable as first argument, but only as last postfix argument ?

list = {100, 200, 300, 400, 500};
Array[list[[#]] &, Length[#]] &@list

Expected result:

{100, 200, 300, 400, 500}

EDIT: I'm expect 1st argument in the form body &, and not something like Function[x, body] or definition of new nonpure function.

$\endgroup$

marked as duplicate by Carl Woll, Mr.Wizard Nov 20 '17 at 22:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ I would just write list = {100, 200, 300, 400, 500}; f[n_] := list[[n]]; Array[f, Length@list] and it is simpler also :) $\endgroup$ – Nasser Nov 20 '17 at 22:23
3
$\begingroup$

This is basically a duplicate of pure functions in nested select. Applying the accepted answer to your question:

list = {100, 200, 300, 400, 500};
Array[Function[x, #[[x]]], Length[#]]& @ list

{100, 200, 300, 400, 500}

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.