Axiom, 251 bytes
C==>concat;A==>List Any;px(a:A):A==(k:=#a;r:=copy[a];k<=1=>r;i:=1;repeat(i>=k=>break;x:=a.(1..i);y:=a.((i+1)..k);z:=px(y);t:=[x,z.1];for j in 2..#z repeat(w:=(z.j)::A;m:=#w;v:=[x];for q in 1..m repeat v:=C(v,w.q);t:=C(t,[v]));r:=C(r,copy t);i:=i+1);r)
If someone find something better...ungof and test:
pp(a:List Any):List Any==
k:=#a;r:=copy[a];k<=1=>r;i:=1
repeat
i>=k=>break
x:=a.(1..i);y:=a.((i+1)..k);z:=pp(y);
t:=[x,z.1]
for j in 2..#z repeat
w:=(z.j)::List Any
m:=#w; v:=[x]
for q in 1..m repeat
v:=concat(v,w.q);
t:=concat(t,[v])
r:=concat(r,copy t);
i:=i+1
r
(7) -> px []
(7) [[]]
Type: List Any
(8) -> px [1]
(8) [[1]]
Type: List Any
(9) -> px [1,2]
(9) [[1,2],[[1],[2]]]
Type: List Any
(10) -> px [1,2,3]
(10) [[1,2,3],[[1],[2,3]],[[1],[2],[3]],[[1,2],[3]]]
Type: List Any
(11) -> px [1,2,3,4,5,6]
(11)
[[1,2,3,4,5,6], [[1],[2,3,4,5,6]], [[1],[2],[3,4,5,6]],
[[1],[2],[3],[4,5,6]], [[1],[2],[3],[4],[5,6]], [[1],[2],[3],[4],[5],[6]],
[[1],[2],[3],[4,5],[6]], [[1],[2],[3,4],[5,6]], [[1],[2],[3,4],[5],[6]],
[[1],[2],[3,4,5],[6]], [[1],[2,3],[4,5,6]], [[1],[2,3],[4],[5,6]],
[[1],[2,3],[4],[5],[6]], [[1],[2,3],[4,5],[6]], [[1],[2,3,4],[5,6]],
[[1],[2,3,4],[5],[6]], [[1],[2,3,4,5],[6]], [[1,2],[3,4,5,6]],
[[1,2],[3],[4,5,6]], [[1,2],[3],[4],[5,6]], [[1,2],[3],[4],[5],[6]],
[[1,2],[3],[4,5],[6]], [[1,2],[3,4],[5,6]], [[1,2],[3,4],[5],[6]],
[[1,2],[3,4,5],[6]], [[1,2,3],[4,5,6]], [[1,2,3],[4],[5,6]],
[[1,2,3],[4],[5],[6]], [[1,2,3],[4,5],[6]], [[1,2,3,4],[5,6]],
[[1,2,3,4],[5],[6]], [[1,2,3,4,5],[6]]]
Type: List Any
(12) -> [[i,#px i] for i in [[],[1],[1,2],[1,2,3],[1,2,3,4],[1,2,3,4,5,6]] ]
(12)
[[[],1],[[1],1],[[1,2],2],[[1,2,3],4],[[1,2,3,4],8],[[1,2,3,4,5,6],32]]
Type: List List Any
(13) -> [#px(i) for i in [[],[1],[1,2],[1,2,3],[1,2,3,4],[1,2,3,4,5,6]] ]
(13) [1,1,2,4,8,32]
Type: List NonNegativeInteger
If this is too much space say that and I remove examples...
2Can we omit the surrounding
[...]
in the output format? (As long as partitions are clearly separated, e.g. by linefeeds.) – Martin Ender – 2017-05-18T17:11:27.517Input and output formats are flexible, but they should be the similar. So if the input list has its elements on one line, the output lists should, too. – mbomb007 – 2017-05-18T17:27:40.743
That's not what I mean. Have a look at the Bash answer. It uses
:
as the list separator but in the output, partitions themselves aren't wrapped in an additional pair of[...]
. – Martin Ender – 2017-05-18T17:30:48.317Or, asked differently: in your example format in the challenge, can I drop the first
[
and last]
from each line? – Martin Ender – 2017-05-18T17:32:26.100Is it okay, if my output lists are inside another list? like
[[[1, 2]], [[1], [2]]...]
– kalsowerus – 2017-05-18T17:36:51.680@mbomb007 It's essentially what the Bash answer does (just using
:
for,
and space for linefeed). And it would save 8 bytes or so in Retina, but I can't tell you whether to allow it or not. – Martin Ender – 2017-05-18T17:37:44.867@MartinEnder Sure, I guess it's fine. – mbomb007 – 2017-05-18T17:38:13.350
@mbomb007 "No."? You mean we can't just return a list containing all partitions? o_O (I believe that's what all the non-string-processing answers do.) – Martin Ender – 2017-05-18T17:38:25.567
I would argue (of course I would - I'm biased) that the I/O formats in my answer are fine, because I don't think there are any ambiguities. However I will happily take whatever decision comes down... – Digital Trauma – 2017-05-18T17:38:38.347
@MartinEnder I couldn't tell what the user was asking. Yes that's okay. – mbomb007 – 2017-05-18T17:39:20.217
1Same question as tips – xnor – 2017-05-18T19:02:06.357