#
# cox_order(R1,R2) returns true if R1 precedes R2 in the canonical ordering
# of irreducible components of a root system 
#
`coxeter/cox_order`:=proc(R1,R2) local L1,L2;
  if type(R1,'indexed') then L1:=op(0,R1) else L1:=substring(R1,1..1) fi;
  if type(R2,'indexed') then L2:=op(0,R2) else L2:=substring(R2,1..1) fi;
  if L1<>L2 then lexorder(L1,L2)
    elif L1='I2' then evalb(op(R1)<=op(R2))
    elif length(R1)=length(R2) then lexorder(R1,R2)
    else evalb(length(R1)<length(R2))
  fi;
end:
#
save `coxeter/cox_order`, cat(HomeLib,`/coxeter/cox_order.m`);
quit;

