Re: Convert list into function
- To: mathgroup at smc.vnet.net
- Subject: [mg41535] Re: [mg41523] Convert list into function
- From: Bobby Treat <drmajorbob+MathGroup3528 at mailblocks.com>
- Date: Mon, 26 May 2003 05:46:16 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Define
f[n_]:=L[[n]]
or
f[n_Integer]/;a<=n<=Length[L]:=L[[n]]
Bobby
-----Original Message-----
From: rbhatnagar <rajb at stanford.edu>
To: mathgroup at smc.vnet.net
Subject: [mg41535] [mg41523] Convert list into function
Hi,
A simple question: What is the correct way of converting a list into a
function?
For instance, lets say I have some list
L = {1, 2, 3, 4}
and I want a function such that FuncL[1] would return 1, FuncL[2] would
return 2 and so on. So what is the syntax for FuncL?
I need the function for some further manipulation in a situation in
which
simply using L[[1]] would not be appropriate.
Thanks,
R. Bhatnagar