permute([],[]).
permute(L,[EL|T]):- delete(EL,L,L1),permute(L1,T).
delete(X,[X|T],T).
delete(X,[H|T],[H|T1]):- delete(X,T,T1).

%query: permute([T1 = []$ [X|T1]], [T2 = MAX]).
