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?
listex = {MemoryInUse[], f[x], MemoryInUse[], difference}; difference = listex[[3]] - listex[[1]]; listex
? $\endgroup$Append
? Can you describe in more details what you want to do and why you want to do it? The why will help us understand the what better. $\endgroup$Dynamic
's witchcraft seems to be able to handle such recursive definitions asle={1,2,Dynamic[le[[1]]+le[[2]]]}
flawlessly. $\endgroup$