List partitioning



Hi,

I'm looking for a way to get all the partitionings of N items into P groups (each group must have a size of either "int(N/P)" or "int(N/P)+1"). But I don't want any duplicate.

For example, with N=5 and P=2, I want to obtain:

[[i1,i2,i3],[i4,i5]],
[[i1,i2,i4],[i3,i5]],
[[i1,i2,i5],[i3,i4]],
[[i1,i2],[i3,i4,i5]],
[[i1,i3,i4],[i2,i5]],
[[i1,i3,i5],[i2,i4]],
[[i1,i3],[i2,i4,i5]],
[[i1,i4,i5],[i2,i3]],
[[i1,i5],[i2,i3,i4]]

but I dont want to obtain both [[i1,i2,i3],[i4,i5]] and [[i5,i4],[i3,i1,i2]], which are semanticaly equivalent in my context.

Is there a efficient way to do this in Prolog ?

Thanks in advance.
.