This is an extension of my previous post $P=QR$ decomposition of given list
Now for this time, I want to decompose arbitrary list $P$ into three pieces for ordered or non-ordered cases.
Based on the response of @Bill, I consider $P=QR'$ and make $R'=RS$ decomposition, but I realized my input $R$ is no longer a list but a array of lists.
For example, based on the code from @Bill,
P={a1,a2,a3,a4};
(*ordered*)
Q=Table[Take[P,i],{i,Length[P]-1}]
R=Table[Drop[P,i],{i,Length[P]-1}]
(*unordered*)
Q=Subsets[P,{1,Length[P]-1}]
R=Map[Complement[P,#]&,Q]
To decompose $R$ into $R_1, R_2$, For each case of an array $Q$, I mean $Q[[i]]$, assign $R[[i]]$ as $P$ and then do the similar thing.
I want my code to do for the arbitrary given list, but this case, it seems not good.
Actually, I need $P=QRST$ decomposition but with $P=QRS$ I think I can handle $P=QRST$ decomposition easily.
For unordered case; following are my wrong trials using "for"
P = {a1, a2, a3};
Q = Subsets[P, {1, Length[P] - 1}]
R1 = Map[Complement[P, #] &, Q]
For[i = 1, i <= Length[R1], i++,
R[[i]]=Subsets[R1[[i]], {1, Length[R1[[i]]] - 1}];
S[[i]]=Complement[R1[[i]], R[[i]] ]; ]
First of all, I notice my decomposition is totally wrong. Dividing the size of element of $Q$ is right, but the number is wrong. Even for three entries and dividing into three parts, the size two should be neglected but the above does not care about it. And Identifying R[[i]] is also totally wrong, because what Susbsets[R1[[1]],{1, Length[R1[[1]]] - 1}] = {{a2},{a3}}....
After @Bill 's response to this post, I realized to make it work for unordered partitions, there should be
v=Map[TakeList[P,#]&,Flatten[Map[Permutations,IntegerPartitions[Length[P],{3}]],1]];
for the unordered subsets. First I think of splitting the given array into three; then realized the Mathematica splits the list in an ordered way. i.e., splitting {1,2,3} into three it only produce {{1},{2},{3}}