As part of some data anaylsis, I am using the function Trace to give me the name of an array of data, which I then use to label my plots.
eg. my data array is called r1 so I run:
ToString@((Trace[r1])[[1]])
which simply returns the string "r1".
All fine and dandy.
The problem arises when I try to do this for a list of data arrays, I write:
Trace[#]&/@{r1,r2}
which I expect to give me the list {"r1","r2"}. Instead I get {{},{}}.
What am I doing wrong?
Any help will be much appreciated!
{r1, r2}is evaluated first, so the symbols are replaced by their values beforeTracesees them. – Simon Woods Jul 24 '14 at 12:07Trace[#][[1]] & /@ {Unevaluated@r1, Unevaluated@r2}– Öskå Jul 24 '14 at 12:22(I'm not sure the etiquette here for asking follow-up but related questions).
Is there a way to prevent r1, r2 from being evaluated where I still pass the list {r1,r2} (as opposed to) {Unevaluated@r1, Unevaluated@r2}? I assumed something like:
might work, but it still seems to be evaluating the list {r1,r2} first.
– Mashy Jul 24 '14 at 12:48