This is a generalization of this question, which already has very nice answers.
Suppose str
is a string of valid code, so that ToExpression[str]
generates an output. I can copy/paste the contents of str
into a cell and then evaluate this cell manually.
But I'd like to automate the process of generating an input cell containing the contents of str
. That is, I'm looking for a function makeCell[str_]
that generates an input cell with the contents of str
. This seems doable because it can be done by copy/pasting, and functions like ToExpression
and CellPrint
exist (see above post and this one for specific examples). But so far I haven't found a solution.
Is this possible?