MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: SubValues

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71890] Re: SubValues
  • From: "Philipp" <Philipp.M.O at gmail.com>
  • Date: Sat, 2 Dec 2006 05:11:29 -0500 (EST)
  • References: <ekmf8k$8pr$1@smc.vnet.net>

In[1]:=  Clear[f];
         Scan[(f[#[[1]]][#[[2]]] = 10 #[[1]] + #[[2]]) &,
              Table[Random[Integer, {1, 10}], {20}, {2}]]

In[4]:=  SubValues[f]

Out[4]=
{HoldPattern[f[1][1]] :> 11,
  HoldPattern[f[1][5]] :> 15,
  HoldPattern[f[1][7]] :> 17,
  HoldPattern[f[1][10]] :> 20,
  HoldPattern[f[4][5]] :> 45,
  HoldPattern[f[5][1]] :> 51,
  HoldPattern[f[5][10]] :> 60,
  HoldPattern[f[6][8]] :> 68,
  HoldPattern[f[6][10]] :> 70,
  HoldPattern[f[7][1]] :> 71,
  HoldPattern[f[7][4]] :> 74,
  HoldPattern[f[7][5]] :> 75,
  HoldPattern[f[7][6]] :> 76,
  HoldPattern[f[8][3]] :> 83,
  HoldPattern[f[8][8]] :> 88,
  HoldPattern[f[9][5]] :> 95,
  HoldPattern[f[9][7]] :> 97}

Cheers,

Philipp.


dimitris wrote:
> I noticed the following:
>
> \!\(f\_i[x_] := x\^i\)
>
> \!\(\((f\_#1[x] &)\) /@ Range[10]\)
> Out[6]
> \!\({f\_1[x], f\_2[x], f\_3[x], f\_4[x], f\_5[x], f\_6[x], f\_7[
>     x], f\_8[x], f\_9[x], f\_10[x]}\)
>
> ?f
> Global`f
>
> After I converted to InputForm
>
> Subscript[f, i][x_] := x^i
>
> (Subscript[f, #1][x] & ) /@ Range[10]
> {Subscript[f, 1][x], Subscript[f, 2][x],
>   Subscript[f, 3][x], Subscript[f, 4][x],
>   Subscript[f, 5][x], Subscript[f, 6][x],
>   Subscript[f, 7][x], Subscript[f, 8][x],
>   Subscript[f, 9][x], Subscript[f, 10][x]}
>
> And I tried
>
> SubValues[Subscript]
> {HoldPattern[Subscript[f, i][x_]] :> x^i}
>
> taking what I want (i.e. where the definition is stored)
>
> Information["SubValues", LongForm -> False]
> "SubValues[f] gives a list of transformation rules \
> corresponding to all subvalues (values for \
> f[x,..][..], etc.) defined for the symbol f."
>
> Can somebody provide me with further examples of "storing" in
> SubValues?
> 
> Regards
> Dimitris


  • Prev by Date: calculation speed
  • Next by Date: Re: Ask Mathematica to sub for a long expression
  • Previous by thread: calculation speed
  • Next by thread: When I Get[] a package - how can I tell where the error message came from?