0
$\begingroup$

Abstract I have a function objectName that gets SymbolName and value. I would like to apply this to many variables at once with another function that applies to each argument with unknown number of them. I would prefer not to list them but just throw them in as arguments much like the function 'Plus[a,b,c,...]' but would output results as pairs in a list {{name[a],value[a]},{name[b],value[b]},{name[c],value[c]},...}. I cannot seem to get it to work.

objectName = Function[Null, {SymbolName[Unevaluated[#]], Evaluate[symbol]}, {HoldFirst}];
dataIn[#__] := Function[Null, objectName[#__], Listable];
$\endgroup$
0

1 Answer 1

1
$\begingroup$

This might work:

objectName = Function[Null,
  ReleaseHold[
   Map[
    Function[Null, {SymbolName[Unevaluated[#]] , #}, HoldAll],
    Hold[{##}],
    {2}
    ]
   ],
  HoldAll
  ]

Example:

a = 1;
 objectName[a, b, c, d]

{{"a", 1}, {"b", b}, {"c", c}, {"d", d}}

$\endgroup$
2
  • $\begingroup$ thank you but I need variable number of arguments to work for the dataIn[]. $\endgroup$ Jun 8, 2020 at 22:46
  • $\begingroup$ @Henrik-Schumaker yes of course. but it needs to work in the dataIn so it could create rows of name-value pairs for presentation of variables and their values. an auxiliary function dataOut would present the results of calculations in name-value pairs. $\endgroup$ Jun 8, 2020 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.