Path: utzoo!attcan!uunet!mcvax!unido!ecrcvax!bruno From: bruno@ecrcvax.UUCP (Bruno Poterie) Newsgroups: comp.lang.prolog Subject: Re: small prolog problem Keywords: 4 liner Message-ID: <541@ecrcvax.UUCP> Date: 20 May 88 07:30:23 GMT References: <53640@sun.uucp> Reply-To: bruno@ecrcvax.UUCP (Bruno Poterie) Organization: ECRC, Munich 81, West Germany Lines: 10 Posted: Fri May 20 08:30:23 1988 a straightforward solution, but probably not the optimal one, is: permute_list( [], []). permute_list( InitList, [NewFirst|NewRest]) :- choose_first( InitList, NewFirst, InitRest), permute_list( InitRest, NewRest). choose_first( [First|Rest], First, Rest). choose_first( [First|Rest1], Elem, [First|Rest2]) :- choose_first( Rest1, Elem, Rest2).