🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3394

Re: small prolog problem

#3394
From: Bruno Poterie
Date: Fri, 20 May 1988 07:30
10 lines
768 bytes
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).
Technical Details
Message-ID: <541@ecrcvax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!unido!ecrcvax!bruno
References: <53640@sun.uucp>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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