3

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}, {{}}}
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
lio
  • 2,396
  • 13
  • 26

2 Answers2

7

Use Replace with level spec {-1}:

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

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

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
4

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}, {{}}}

m_goldberg
  • 107,779
  • 16
  • 103
  • 257