Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

RE: How to define new function using the previous output?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36396] RE: [mg36375] How to define new function using the previous output?
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Wed, 4 Sep 2002 21:22:07 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

>-----Original Message-----
>From: Peter [mailto:psutovsk2 at hotmail.com]
To: mathgroup at smc.vnet.net
>Sent: Wednesday, September 04, 2002 8:56 AM
>Subject: [mg36396] [mg36375] How to define new function using the 
>previous output?
>
>
>Hello,
>
>What is a efficient way to use output expression to define new 
>function.
>
> Thank you,
>                                   Peter
>
>
>
>
Peter,

I'd say none,... 'cause look at
 
In[1]:= y = x^2
Out[1]= x^2

In[2]:= f1[x_] = Out[1]
Out[2]= x^2

In[3]:= f2[x_] := Out[1]

In[4]:= x = 5
Out[4]= 5

In[5]:= f3[x_] = Out[1]
Out[5]= 25

In[6]:= Block[{x}, f4[x_] = Out[1]]
Out[6]= 25

In[7]:= Block[{x}, f5[x_] := Out[1]]

In[8]:= $HistoryLength = 11;

In[9]:= f6[x_] = y
Out[9]= 25

In[10]:= Block[{x}, f7[x_] = y]
Out[10]= 25

In[11]:= f8[x_] := y

In[12]:= 
Through[{f1, f2, f3, f4, f5, f6, f7, f8}[#]] & /@ {0, 1}
Out[12]= {{0, 25, 25, 0, 25, 25, 0, 25},
          {1, 25, 25, 1, 25, 25, 1, 25}}

In[13]:= Block[{x}, f9[x_] = Out[1]]
Out[13]= %1

In[14]:= 
Through[{f1, f2, f3, f4, f5, f6, f7, f8, f9}[#]] & /@ {0, 1}
Out[14]= {{0, %1, 25, 0, %1, 25, 0, 25, %1},
          {1, %1, 25, 1, %1, 25, 1, 25, %1}}

f1, f4 and f7 come out right, but f1 is based on the condition that the
pattern variables of the expression have not been redefined, and f4 is only
correct if the history is remembered well. So what rests is f7, but that
wasn't you question.

--
Hartmut Wolf



  • Prev by Date: Re: List argument
  • Next by Date: Re: Re: approximation for partitial binomial sum
  • Previous by thread: Re: How to define new function using the previous output?
  • Next by thread: List argument