Message Boards Message Boards

Can I create a function by assigning list elements?

Posted 10 years ago
2 Replies

Thank you.

In[1]:= list1 = Range[5];

In[5]:= list2 = RandomReal[{0, 1}, 5]

Out[5]= {0.616207, 0.0909475, 0.963306, 0.63963, 0.714089}

In[6]:= Do[f[list1[[i]]] = list2[[i]], {i, 5}]

In[7]:= ?f

Global`f

f[1]=0.616207

f[2]=0.0909475

f[3]=0.963306

f[4]=0.63963

f[5]=0.714089
POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract