Re: Help with a function to return the 'age' of itself
- To: mathgroup at smc.vnet.net
- Subject: [mg61439] Re: [mg61392] Help with a function to return the 'age' of itself
- From: "Carl K. Woll" <carl at woll2woll.com>
- Date: Wed, 19 Oct 2005 02:16:23 -0400 (EDT)
- References: <200510180644.CAA11166@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
heycarnut wrote: > I'm trying to create a function, that when instantiated, keeps a 'copy' > of say the current absolute time, but when the instance is called, it > returns the delta between this 'copy' of the time and the current > absolute time. I have done this: > > > In[47]:= tt:=Hold[AbsoluteTime[]]-AbsoluteTime[]; > y=tt; > N[Release[y]] > Pause[10] > N[Release[y]] > > > Out[49]=0. > > Out[51]=10. > > But I don't want to have to do an explicit release, i'd like to just be > able to evaluate y, in this case, and get the current value. > Help? > > Thanks in advance, > Rob > How about: start := With[{cur = AbsoluteTime[]}, y := AbsoluteTime[] - cur] Use start to instantiate your y function: start Now, you can check how long it's been since start: In[16]:= y Pause[2] y Out[16]= 103.5625000 Out[18]= 105.5937500 Let's check the definition of y: In[19]:= ?y Global`y 9 y := AbsoluteTime[] - 3.3386204777812500 10 Carl Woll Wolfram Research
- References:
- Help with a function to return the 'age' of itself
- From: "heycarnut" <heycarnut@gmail.com>
- Help with a function to return the 'age' of itself