MathGroup Archive 1999

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

Search the Archive

Re: A new symbol to "inherit" the definitions from an existing symbol?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17486] Re: A new symbol to "inherit" the definitions from an existing symbol?
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Mon, 10 May 1999 01:44:25 -0400
  • References: <7h4isl$egf@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Phillip,
Some ideas

Attributes[f] = Orderless;
f[x_]:= g[x];
g[x_] := x^2

DownValues[p]=DownValues[f]/.f->p;
Attributes[p] = Attributes[f];

FullDefinition[p]//InputForm

    Attributes[p] = {Orderless}

    p[x_] := g[x]

    g[x_] := x^2

Allan,

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565



Dr Phillip Kent <p.kent at ic.ac.uk> wrote in message
news:7h4isl$egf at smc.vnet.net...
> A colleague just put this to me, and it seems such an obvious
> thing to do but neither of us know how to do it...
>
> I have a fairly complex (mathematical) function set up in terms
> of definitions, up values, down values, attributes, etc etc. All of
> these are directly visible with FullDefinition[]. All I want to do is
> to create a new function that immediately takes on all the definitions
> from a given function. Granted that this may be ill-defined in
> general, but let's assume that I'm going to take responsibility for the
> self-consistency of the operation.
>
> Well, I can see it's not too hard to Save[] the definitions for a
> symbol, Read[] them back in using Hold[]'s, do a substitution rule
> and release the Holds. Or, take the output cell containing the
> FullDefinition[], copy it to an input cell and process that expression.
> But, these are both bizarre procedures.
>
> Suggestions?
>
> -Phillip
>
> ----------------------------------+----------------------------
>  Dr Phillip Kent                  | tel: +44 (0)171 594 8503
>  The METRIC Project               | fax: +44 (0)171 594 8517
>  Mathematics Department           |
>  Imperial College                 | p.kent at ic.ac.uk
>  London SW7 2BZ, U.K.             | http://metric.ma.ic.ac.uk/
> ----------------------------------+----------------------------
>        "Ask not what you can do TO your data structures,
>           Ask what your data structures can do FOR you."
>



  • Prev by Date: Re: Plotting Problem
  • Next by Date: Re: Why Round[5/2]=2?
  • Previous by thread: A new symbol to "inherit" the definitions from an existing symbol?
  • Next by thread: Re: A new symbol to "inherit" the definitions from an existing symbol?