From: David Reiss on
In[9]:= f[x_] := x

In[10]:= UpValues[f]

Out[10]= {}

In[11]:= DownValues[f]

Out[11]= {HoldPattern[f[x_]] :> x}

In[12]:= ?? f

Global`f

f[x_]:=x



--David

On Apr 11, 4:33 am, Michael Young <michaelcharlesyo...(a)earthlink.net>
wrote:
> Hello,
>
> I seem to have accidentally 'orphaned' three functions i built .
>
> That is, the code is still active in memory, and the function name
> shows in black and displays its intended data ; however, the file's
> copies of the functions' source-code have been modified and recompiled
> under different names, for different purposes .
>
> Is there a way to retrieve function source-code in Mathematica ?
>
> Michael


From: becko on
Perhaps you can try something like:

f[x_] := x^2

?? f

The line input ??f should return the code to your function.


--------------------------------------------------
From: "Michael Young" <michaelcharlesyoung(a)earthlink.net>
Sent: Sunday, April 11, 2010 3:33 AM
To: <mathgroup(a)smc.vnet.net>
Subject: Retrieving orphaned code

> Hello,
>
>
> I seem to have accidentally 'orphaned' three functions i built .
>
> That is, the code is still active in memory, and the function name
> shows in black and displays its intended data ; however, the file's
> copies of the functions' source-code have been modified and recompiled
> under different names, for different purposes .
>
> Is there a way to retrieve function source-code in Mathematica ?
>
>
> Michael
>
>

From: dh on
On 11.04.2010 10:33, Michael Young wrote:
> Hello,
>
>
> I seem to have accidentally 'orphaned' three functions i built .
>
> That is, the code is still active in memory, and the function name
> shows in black and displays its intended data ; however, the file's
> copies of the functions' source-code have been modified and recompiled
> under different names, for different purposes .
>
> Is there a way to retrieve function source-code in Mathematica ?
>
>
> Michael
>

Hi Michael,
Information[..] (or ?? for short) gives ther definitions.
cheers, Daniel

--

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh(a)metrohm.com>
Internet:<http://www.metrohm.com>


From: Bob Hanlon on

f[a_, b_, c_, x_] := Module[{d, e, f},
d = a + b/2;
e = Exp[-c*x];
d*x^2 + e*x + c]

DownValues[f] // InputForm

{HoldPattern[f[a_, b_, c_, x_]] :> Module[{d, e, f},
d = a + b/2; e = Exp[(-c)*x]; d*x^2 + e*x + c]}

However, other Values could have been defined so

n = ToExpression[Names["*Values"]]

{DefaultValues,DownValues,DynamicModuleValues,FormatValues,
NValues,OwnValues,SingularValues,SubValues,UpValues}

Select[{#, #[f]} & /@ n, FreeQ[#[[2]], #[[1]]] &] // Quiet


Bob Hanlon

---- Michael Young <michaelcharlesyoung(a)earthlink.net> wrote:

=============
Hello,


I seem to have accidentally 'orphaned' three functions i built .

That is, the code is still active in memory, and the function name
shows in black and displays its intended data ; however, the file's
copies of the functions' source-code have been modified and recompiled
under different names, for different purposes .

Is there a way to retrieve function source-code in Mathematica ?


Michael


From: John Jowett on
Michael, One way is to evaluate

?functionname

or, possibly,

??functionname

which should display all information on the current definition. You
can then copy and paste what you need into a new input cell.
John

On Apr 11, 10:33 am, Michael Young <michaelcharlesyo...(a)earthlink.net>
wrote:
> Hello,
>
> I seem to have accidentally 'orphaned' three functions i built .
>
> That is, the code is still active in memory, and the function name
> shows in black and displays its intended data ; however, the file's
> copies of the functions' source-code have been modified and recompiled
> under different names, for different purposes .
>
> Is there a way to retrieve function source-code in Mathematica ?
>
> Michael