#
# DPar(n) returns a list of the partitions of n with Distinct Parts.
# DPar(n,l) returns the sublist of DPar(n) with length <=l.
# DPar(n,k,l) returns the sublist of DPar(n) with parts <=k, length <=l.
#
`QF/DPar`:=proc(n)
  if nargs=1 then `QF/DPar/sub`(n,n+1,n)
    elif nargs=2 then `QF/DPar/sub`(n,n+1,args[2])
    else `QF/DPar/sub`(n,args[2]+1,args[3])
  fi
end:
#
`QF/DPar/sub`:=proc(n,row,col) local res,k,m,newstuff;
  if n=0 then RETURN([[]]) fi;
  if n<0 or row<2 or col<1 then RETURN([]) fi;
  m:=min(row-1,col); res:=NULL;
  if 2*n > m*(2*row-m-1) then RETURN([]) fi;
  for k from min(n,row-1) by -1 to 1 do
    newstuff:=`QF/DPar/sub`(n-k,k,col-1);
    if newstuff=[] then break fi;
    res:=res,map(proc(x,y) [y,op(x)] end,newstuff,k);
  od;
  map(op,[res])
end:
#
save `QF/DPar`, `QF/DPar/sub`, cat(HomeLib,`/QF/DPar.m`);
read cat(HomeLib,`/help/QF/DPar`);
quit;

