Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!EU.net!sunic!umdac!fizban.solace.mh.se!news.ifm.liu.se!liuida!curofix!andka
From: andka@IDA.LiU.SE (Andreas Kagedal)
Subject: Re: EQUAL question...
In-Reply-To: crowter@AI.RL.AF.MIL's message of Wed, 12 Oct 1994 16: 51:28 GMT
Message-ID: <ANDKA.94Oct13074806@aste31.IDA.LiU.SE>
Sender: news@ida.liu.se
Organization: CIS Dept, University of Linkoping, Sweden
References: <1994Oct11.141818@iowasp.physics.uiowa.edu> <37eu3a$p3l@elna.ethz.ch>
	<crowter.781979970@ai.rl.af.mil> <crowter.781980688@ai.rl.af.mil>
Date: Thu, 13 Oct 1994 06:48:05 GMT
Lines: 24

John Crowter writes:

   Actually, to cover all cases, I should have included

   first_equals_last([X]).
   first_equals_last(FirstAndLastEqualList) :-
   >   append([X|_],[X],FirstAndLastEqualList).

To cover all cases (i.e. including the list-of-length-one case) in one
clause one could write:

first_equals_last(FirstAndLastEqualList) :-
      FirstAndLastEqualList = [X|_],
      append(_,[X],FirstAndLastEqualList).

I dno't know if this would be "better" in any sense, though.

/Andreas
--
----------------------------------- < * > ------------------------------------
Andreas Kagedal                                email: andka@IDA.LIU.SE
Dep. of Computer and information science
University of Linkoping, Sweden

