I've tried 3 methods but all failed to do that.
1st Method
Apply[Flatten, {1, {2, {3, 4}, 5}, 6}, {2}]
2nd Method
Map[Flatten, {1, {2, {3, 4}, 5}, 6}, {2}]
3rd Method
Flatten[{1, {2, {3, 4}, 5}, 6}, {2}]
I wanna get {1, {2, 3, 4, 5}, 6}
{a, {b, c}, {d e}, f} -> {a,b,c,d,e,f}
. You might be asking "assuming things are nested x -> (A x B), flatten the deepest" (not the case since presumably you want this to also work on{1,{2,3,4,5},6}
). You might be asking "flatten the second element". You might be asking "flatten the second element by one level". You need to either specify the problem unambiguously, and/or provide like 10 all-encompassing edge-case examples (e.g. the empty list, etc.). $\endgroup$