Hi,
On Wed, Oct 14, 2009 at 4:23 PM, Martin Morgan wrote:
> Steve Lianoglou wrote:
>> Very clever, that looks to do the trick!
>
> I think though that all Square's then share the same environment
> (created in the prototype) and hence area.
>
>> area(new("Square", length=50, width=100))
> Accessi
Just a note: this technique is called memoisation.
Hadley
On Wed, Oct 14, 2009 at 3:42 PM, Benilton Carvalho wrote:
> Thank you very much, Martin. :)
>
> b
>
> On Oct 14, 2009, at 5:23 PM, Martin Morgan wrote:
>
>> Steve Lianoglou wrote:
>>>
>>> Very clever, that looks to do the trick!
>>
>> I th
Thank you very much, Martin. :)
b
On Oct 14, 2009, at 5:23 PM, Martin Morgan wrote:
Steve Lianoglou wrote:
Very clever, that looks to do the trick!
I think though that all Square's then share the same environment
(created in the prototype) and hence area.
area(new("Square", length=50, wid
Steve Lianoglou wrote:
> Very clever, that looks to do the trick!
I think though that all Square's then share the same environment
(created in the prototype) and hence area.
> area(new("Square", length=50, width=100))
Accessing
[1] 50
Which is quite efficient at doing the calculation, but maybe
Very clever, that looks to do the trick!
Thanks,
-steve
On Oct 14, 2009, at 2:57 PM, Benilton Carvalho wrote:
If you change 'area' to an environment, you may be able to get
something close to what you want.
For example:
setClass("Square",
representation(
len
If you change 'area' to an environment, you may be able to get
something close to what you want.
For example:
setClass("Square",
representation(
length='numeric',
width='numeric',
area='environment'
Hi,
I was wondering if there was a way to store the results of a
computationally expensive "getter" call on an S4 object, so that it is
only calculated once for each object.
Trivial example: let's say I want to cache the "expensive" area
calculation of a square object.
setClass("Square"
7 matches
Mail list logo