3
$\begingroup$

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$
1

2 Answers 2

7
$\begingroup$

Use Replace with level spec {-1}:

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

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

$\endgroup$
0
4
$\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.