Re: Table Lookup Function?
- To: mathgroup at smc.vnet.net
- Subject: [mg38652] Re: Table Lookup Function?
- From: "Albert REINER" <Use-Author-Address-Header at [127.1]>
- Date: Fri, 3 Jan 2003 00:15:29 -0500 (EST)
- Organization: mail2news@nym.alias.net
- References: <auqnt3$6tv$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On Tue, Dec 31, 2002 at 12:20:50AM +0000, Frank Iannarilli wrote: ... > myFunc[i_Integer] = Table[n, {n, 1, 10}][[i]] > > so when I invoke it with an index argument i: > myFunc[3] ... > This works, but nonetheless, upon defining the function, Mathematica returns > the "error message": > Part::"pspec": "Part specification i is neither an integer nor a > list > of integers." You need to control the sequence of evaluations; try (not tested) With[{table=Table[n, {n, 1, 10}]}, myFunc[i_Integer] := table[[i]]] Albert.