function partitions(sequence s) integer N = sum(s) sequence set = tagset(N), perm, results = {}, result, resi for i=1 to factorial(N) do perm = permute(i,set) integer n = 1 result = {} for j=1 to length(s) do resi = {} for k=1 to s[j] do resi = append(resi,perm[n]) n += 1 end for result = append(result,sort(resi)) end for if not find(result,results) then results = append(results,result) end if end for return sort(results) end function ppOpt({pp_Nest,1}) pp(partitions({2,0,2})) pp(partitions({1,1,1})) pp(partitions({1,2,0,1})) pp(partitions({})) pp(partitions({0,0,0}))