Re: Functions with data hidden in them
- To: mathgroup at smc.vnet.net
- Subject: [mg81861] Re: Functions with data hidden in them
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 5 Oct 2007 04:49:42 -0400 (EDT)
- References: <fe28v5$muq$1@smc.vnet.net>
Hi,
the old version used Format[], a bit newer is something like
MakeBoxes[myfun[lst_, x_], fmt_: StandardForm] :=
RowBox[{"\[ScriptCapitalF]", "[", MakeBoxes[x, fmt], "]"}]
and you will see that
myfun[{1, 2, 3, 4}, x]
will hide the first argument in output
Regards
Jens
Neil Stewart wrote:
> The Interpolation[] function somehow "hides" the data passed to it in the
> InterpolationFunction object that it returns. In the example below, when
> f[1] is evaluated it is using information from the list data, but does not
> have the list data passed to it as parameter.
>
> In[1]:= data = {{1, 1}, {2, 2}, {3, 3}}
>
> In[2]:= f = Interpolation[data]
>
> In[3]:= f[1]
> Out[3]= 1
>
> How can I write my own function that stores data inside itself in the same
> way that Interpolation does? I'm aiming to write a functions that takes a
> number as a parameter and consults a large data set to return a number. I'm
> not sure where to start - any ideas very welcome!
>
> Thanks,
> Neil.
>
>