Skip to main content
Tweeted twitter.com/StackMma/status/659248890659651584
corrected my acronymous dyslexia
Source Link
IPoiler
  • 1.2k
  • 9
  • 15

I'm looking for a way to reference an element within a List to get another element in the same parent List. I can't really see any way to do this without either being able to specify a level that is above that element in a getter function or without some kind of self-referencing construct like .this() for object-oriented ABDsADTs.

As a minimal example, is there a way to get

listex={MemoryInUse[],f[x],MemoryInUse[],difference}

where difference=listex[[3]]-listex[[1]], or is my sole option to generate a List without these dependent elements and then Insert/Append them post-creation?

I'm looking for a way to reference an element within a List to get another element in the same parent List. I can't really see any way to do this without either being able to specify a level that is above that element in a getter function or without some kind of self-referencing construct like .this() for object-oriented ABDs.

As a minimal example, is there a way to get

listex={MemoryInUse[],f[x],MemoryInUse[],difference}

where difference=listex[[3]]-listex[[1]], or is my sole option to generate a List without these dependent elements and then Insert/Append them post-creation?

I'm looking for a way to reference an element within a List to get another element in the same parent List. I can't really see any way to do this without either being able to specify a level that is above that element in a getter function or without some kind of self-referencing construct like .this() for object-oriented ADTs.

As a minimal example, is there a way to get

listex={MemoryInUse[],f[x],MemoryInUse[],difference}

where difference=listex[[3]]-listex[[1]], or is my sole option to generate a List without these dependent elements and then Insert/Append them post-creation?

Source Link
IPoiler
  • 1.2k
  • 9
  • 15

Referencing previous elements in the same List

I'm looking for a way to reference an element within a List to get another element in the same parent List. I can't really see any way to do this without either being able to specify a level that is above that element in a getter function or without some kind of self-referencing construct like .this() for object-oriented ABDs.

As a minimal example, is there a way to get

listex={MemoryInUse[],f[x],MemoryInUse[],difference}

where difference=listex[[3]]-listex[[1]], or is my sole option to generate a List without these dependent elements and then Insert/Append them post-creation?