Skip to main content
2 of 3
deleted 80 characters in body
kglr
  • 400.5k
  • 18
  • 488
  • 929
lst = {1 -> a, 2 -> {3 -> c, 4 -> d, 5 -> {6 -> f, 7 -> {8 -> h}}}}

lst //. Rule[a : Except[_z], b_] :> Rule[z @ a, b]

{z[1] -> a, z[2] -> {z[3] -> c, z[4] -> d, z[5] -> {z[6] -> f, z[7] -> {z[8] -> h}}}}

kglr
  • 400.5k
  • 18
  • 488
  • 929