This is a new twist of an earlier question about how to get variable names as strings from a function.
I would like to have a function that returns a list of variable names, each being a string, from a list of variables. The goal is to be able to generate a grid that lists the variable name in one column, and the variable values in another, and to iterate this over a list of variables. I have tried:
a = {1, 2, 3, 4, 5};
b = {2, 4, 6, 8};
c = {1, 3, 5, 7};
Clear[varName]
SetAttributes[varName, HoldFirst]
varName[var_] := SymbolName[Unevaluated@var];
{varName[#], Length[#]} & /@ {a, b, c}
which does not yield symbol name. The closest I have come is this (using Length as an example function)
{ToString@#, Length @@ #} & /@ HoldForm /@ Unevaluated@{a, b, c}
{{"a", 5}, {"b", 4}, {"c", 4}}
What I can't figure out is how to define this as a function
func[varlist_]:={ToString@#, Length @@ #} & /@ HoldForm /@ Unevaluated@varlist
func[{a,b,c}]
Desired result: {{"a", 5}, {"b", 4}, {"c", 4}}
Thanks!