Re: Why does the order of down values come back?

*To*: mathgroup at smc.vnet.net*Subject*: [mg124813] Re: Why does the order of down values come back?*From*: DrMajorBob <btreat1 at austin.rr.com>*Date*: Wed, 8 Feb 2012 05:28:23 -0500 (EST)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*References*: <jgo0e9$a2k$1@smc.vnet.net> <201202070905.EAA23510@smc.vnet.net>*Reply-to*: drmajorbob at yahoo.com

I suspect the unsorted version is irrelevant, however, in that when f[something] is evaluated, rules will be tested from most specific to least. Bobby On Tue, 07 Feb 2012 03:05:34 -0600, Oleksandr Rasputinov <oleksandr_rasputinov at ymail.com> wrote: > On Mon, 06 Feb 2012 07:45:13 -0000, Shizu <slivo.vitz at msa.hinet.net> > wrote: > >> In[]:= f[0] := 0;f[1] := 1;f[n_] := f[n - 1] + f[n - 2] >> >> In[]:= DownValues[f] >> Out[]:= {HoldPattern[f[0]] :> 0, HoldPattern[f[1]] :> 1, >> HoldPattern[f[n_]] :> f[n - 1] + f[n - 2]} >> >> In[]:= DownValues[f] = Reverse[DownValues[f]] >> Out[]:= {HoldPattern[f[n_]] :> f[n - 1] + f[n - 2], HoldPattern[f[1]] :> >> 1, HoldPattern[f[0]] :> 0} >> >> In[]:= DownValues[f] >> Out[]:= {HoldPattern[f[0]] :> 0, HoldPattern[f[1]] :> 1, >> HoldPattern[f[n_]] :> f[n - 1] + f[n - 2]} >> >> ==================================================== >> My question is: >> >> Why does the order of down values comes back after reordering? >> >> Thanks. >> > > Because DownValues sorts its output by default. The actual downvalues are > not, however, sorted; the order is as you set them. To see their actual > order, use the (undocumented) option: > > DownValues[f, Sort -> False] > -- DrMajorBob at yahoo.com

**References**:**Re: Why does the order of down values come back?***From:*"Oleksandr Rasputinov" <oleksandr_rasputinov@ymail.com>