From alfonso@ii.uam.es  Wed Nov  3 17:39:58 1999
Received: from arantxa.ii.uam.es (arantxa.ii.uam.es [150.244.56.15])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id RAA29074
	for <prolog@swi.psy.uva.nl>; Wed, 3 Nov 1999 17:39:57 +0100 (MET)
Received: from minerva.ii.uam.es (minerva [150.244.56.39])
	by arantxa.ii.uam.es (8.8.8+Sun/8.8.8) with ESMTP id RAA13889;
	Wed, 3 Nov 1999 17:40:41 GMT
Received: from priamo.ii.uam.es (priamo.ii.uam.es [150.244.56.62])
	by minerva.ii.uam.es (8.8.8+Sun/8.8.8) with SMTP id RAA13117;
	Wed, 3 Nov 1999 17:33:43 +0100 (MET)
Received: by priamo.ii.uam.es with Microsoft Mail
	id <01BF2622.B7C2BE40@priamo.ii.uam.es>; Wed, 3 Nov 1999 17:41:54 +0100
Message-ID: <01BF2622.B7C2BE40@priamo.ii.uam.es>
From: Alfonso Ortega de la Puente <alfonso@ii.uam.es>
To: "'Luis Iraola Moreno'" <liraola@opera.dia.fi.upm.es>,
        Joakim Örblom
	 <cjorblom@hotmail.com>
Cc: "prolog@swi.psy.uva.nl" <prolog@swi.psy.uva.nl>
Subject: RE: split/3
Date: Wed, 3 Nov 1999 17:41:53 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by swi.psy.uva.nl id RAA29074

The predicate from Luis Iraola seems to be useful...but it changes the type of the arguments that Joakim 
handles.

It could be useful to define the following transformation predicate:


list_chars_list_atoms([], []).
list_chars_list_atoms([A|B], [C|D]) :-
        atom_char(C, A),
        list_chars_list_atoms(B, D).

And use it like this:

atom_chars(axaxxa,L),list_chars_list_atoms(L,LA).

L = [97, 120, 97, 120, 120, 97]
LA = [a, x, a, x, x, a] 

In order to use then the predicate from Luis Iraola

segment(LA, [a], List).




-----Mensaje original-----
De:	Luis Iraola Moreno [SMTP:liraola@opera.dia.fi.upm.es]
Enviado el:	miércoles 3 de noviembre de 1999 13:39
Para:	Joakim Örblom
CC:	prolog@swi.psy.uva.nl
Asunto:	Re: split/3



On Wed, 3 Nov 1999, Joakim Örblom wrote:

> Help! How do I construct a predicate split/3?? E.g. 
> split(a,axxaxxaxx,[xx,xx,xx]).
> Thanx from Carl Orblom (cjorblom@hotmail.com)

This predicate may do the job:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% segment(InputList, SegmentSeparator, SegmentList)
%

segment([], _, []).

segment([X|Y], [H|T], [Segment|Tail]):-
	append(Segment,[H|U], [X|Y]),
	append(T, Rest, U),
	!,
	segment(Rest, [H|T], Tail).

segment([X|Y], _, [[X|Y]]).

Example:

?- segment([a,x,x,a,xx],[a],L).

L=[ [], [x,x], [xx] ] 




----------------
* To UNSUBSCRIBE, please use the HTML form at

    http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist

or send mail to prolog-request@swi.psy.uva.nl using the Subject: "unsubscribe"
(without the quotes) and *no* message body.

** An ARCHIVE of this list is maintained at

    http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/


