I am debugging a ListPlot
implementation and I need to see the command. To avoid huge list of numbers, i just need the ListPlot
like command to return the name of variables it is going to plot. My idea is to do something like HoldForm
but it seems that HoldForm
does not work with Map
if the variable is a list. E.g.
f = {{1, 1}, {2, 2}};
g = {{3, 4}, {5, 6}};
MapThread[q[HoldForm@#1, #2] &, {{f, g}, {a, b}}]
returns
{q[{{1,1},{2,2}},a],q[{{3,4},{5,6}},b]}
Obviously, I want:
{q[{f,a],q[g,b]}
After trial and error I found this to work:
f = {{1, 1}, {2, 2}};
g = {{3, 4}, {5, 6}};
MapThread[
q[HoldForm@#1, #2] &, {{Unevaluated@f, Unevaluated@g}, {a, b}}]
But it is way too cumbersome, I really do not want to put Unevaluated
in front of each list.
Surprisingly, this does not work
MapThread[q[HoldForm@#1, #2] &, {Map[Unevaluated, {f, g}], {a, b}}]
Is there any way to achieve this without having to put Unevaluated
in front of each data list, or even better just keep some kind of Hold
in the function (or first argument of MapThread
? Or is this unachievable as the f
and g
are expanded before getting to the slot? In that case why I cannot map Unevaluated
as in the last example?