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!uunet!psinntp!news.rlcn.rl.af.mil!crowter
From: crowter@AI.RL.AF.MIL (John Crowter)
Subject: Re: EQUAL question...
Message-ID: <crowter.782136119@ai.rl.af.mil>
Sender: news@news.rlcn.rl.af.mil
Nntp-Posting-Host: lestat.ai.rl.af.mil
Organization: Rome Laboratory USAF
References: <1994Oct11.141818@iowasp.physics.uiowa.edu> <37eu3a$p3l@elna.ethz.ch> 	<crowter.781979970@ai.rl.af.mil> <crowter.781980688@ai.rl.af.mil> <ANDKA.94Oct13074806@aste31.IDA.LiU.SE>
Date: Fri, 14 Oct 1994 12:01:59 GMT
Lines: 18

andka@IDA.LiU.SE (Andreas Kagedal) writes:

>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).

Good idea! Taken one step further .....:

first_equals_last([First|AndLastEqualList]) :-
      append(_,[First],[First|AndLastEqualList]).

John Crowter
Rome Laboratory


