3
$\begingroup$

This question already has an answer here:

How can I relpace in a list like this a Symbol by {}:

{x$1273, 14, x$1275}, {25, 33}, {x$1274}}

I would like to get:

{{}, 14, {}}, {25, 33}, {{}}}
$\endgroup$

marked as duplicate by Alexey Popkov, MarcoB, happy fish, gwr, Mr.Wizard Mar 22 '17 at 12:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

6
$\begingroup$

Use Replace with level spec {-1}:

Replace[{{x$1273, 14, x$1275}, {25, 33}, {x$1274}}, _Symbol -> {}, {-1}]

{{{}, 14, {}}, {25, 33}, {{}}}

$\endgroup$
3
$\begingroup$

If you don't want to worry about levels, you can use

{{x$1273, 14, x$1275}, {25, 33}, {x$1274}}/. Except[List, _Symbol] -> {}

{{{}, 14, {}}, {25, 33}, {{}}}

$\endgroup$

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