Re: Convert list into function
- To: mathgroup at smc.vnet.net
- Subject: [mg41561] Re: Convert list into function
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Mon, 26 May 2003 05:46:39 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <bamv2k$13c$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
L={1,2,3,4}
FuncL[i_Integer]/; i>0 && i<Length[L]:=L[[i]]
??
Regards
Jens
rbhatnagar wrote:
>
> 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