2 added 277 characters in body
source | link

The problem: your pattern, {a_, {b___}} will only match a list with exactly two elements, the second of which has to be a list. As you can see, there is no such list anywhere in your expression, which is why it doesn't work.

You can correct it as follows:

sol = list //. {h__Integer, t__List} :> Map[{h} ~Join~ # &, {t}]
(* {{1, 1}, {2, 2}, {{3, 3, 1}, {3, 3, 2}, {{3, 31, 31, 1}, {3, 31, 32, 2}}}} *)

Note that the lists have the correct elements, but are nested. You can again employ rules to "flatten" them out with:

FixedPoint[Replace[#, {x__List} :> x, {1, Infinity}] &, sol]
(* {{1, 1}, {2, 2}, {3, 3, 1}, {3, 3, 2}, {3, 31, 31, 1}, {3, 31, 32, 2}} *)

The problem: your pattern, {a_, {b___}} will only match a list with exactly two elements, the second of which has to be a list. As you can see, there is no such list anywhere in your expression, which is why it doesn't work.

You can correct it as follows:

list //. {h__Integer, t__List} :> Map[{h} ~Join~ # &, {t}]
(* {{1, 1}, {2, 2}, {{3, 3, 1}, {3, 3, 2}, {{3, 31, 31, 1}, {3, 31, 32, 2}}}} *)

The problem: your pattern, {a_, {b___}} will only match a list with exactly two elements, the second of which has to be a list. As you can see, there is no such list anywhere in your expression, which is why it doesn't work.

You can correct it as follows:

sol = list //. {h__Integer, t__List} :> Map[{h} ~Join~ # &, {t}]
(* {{1, 1}, {2, 2}, {{3, 3, 1}, {3, 3, 2}, {{3, 31, 31, 1}, {3, 31, 32, 2}}}} *)

Note that the lists have the correct elements, but are nested. You can again employ rules to "flatten" them out with:

FixedPoint[Replace[#, {x__List} :> x, {1, Infinity}] &, sol]
(* {{1, 1}, {2, 2}, {3, 3, 1}, {3, 3, 2}, {3, 31, 31, 1}, {3, 31, 32, 2}} *)
1
source | link

The problem: your pattern, {a_, {b___}} will only match a list with exactly two elements, the second of which has to be a list. As you can see, there is no such list anywhere in your expression, which is why it doesn't work.

You can correct it as follows:

list //. {h__Integer, t__List} :> Map[{h} ~Join~ # &, {t}]
(* {{1, 1}, {2, 2}, {{3, 3, 1}, {3, 3, 2}, {{3, 31, 31, 1}, {3, 31, 32, 2}}}} *)