ntrans := proc(l) local i,m,j; m := 0; for i to nops(l) do for j from i to nops(l) do if l[j] < l[i] then m := m+1 fi; od; od; RETURN(m); end; sign_of_perm:=proc (l) if type(ntrans(l),even) then 1; else -1; fi; end: # sign_of_perm