From jose.roca@eurocontrol.be  Wed Nov  3 18:48:35 1999
Received: from www.eurocontrol.be (www.eurocontrol.be [193.221.170.226])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id SAA00884
	for <prolog@swi.psy.uva.nl>; Wed, 3 Nov 1999 18:48:34 +0100 (MET)
Received: from mime.eurocontrol.be (mime.eurocontrol.be [193.221.170.180])
	by www.eurocontrol.be (8.8.6 (PHNE_14041)/8.8.6/ER) with ESMTP id SAA19899
	for <prolog@swi.psy.uva.nl>; Wed, 3 Nov 1999 18:48:03 +0100 (MET)
Received: from biscuit.eurocontrol.be (unverified) by mime.eurocontrol.be
 (Content Technologies SMTPRS 2.0.15) with SMTP id <B0002569386@mime.eurocontrol.be>;
 Wed, 03 Nov 1999 18:46:04 +0100
Message-Id: <199911031742.SAA28836@acrux.mis.eurocontrol.be>
Received: by agnbe03.mis.eurocontrol.be with Internet Mail Service (5.5.2448.0)
	id <V6JR7YG2>; Wed, 3 Nov 1999 18:38:24 +0100
From: ROCA Jose <jose.roca@eurocontrol.be>
To: "'Luis Iraola Moreno'" <liraola@opera.dia.fi.upm.es>,
        Joakim Vrblom
	 <cjorblom@hotmail.com>,
        Alfonso Ortega de la Puente <alfonso@ii.uam.es>
Cc: prolog@swi.psy.uva.nl
Subject: RE: split/3
Date: Wed, 3 Nov 1999 18:38:36 +0100 
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.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 SAA00884

And maybe another solution that also produces the output as a list of atoms
and does not contain empty elements:


%split(+Atom,+Atom,-List)

split(A,B,C):-
 atom_chars(A,AC),
 atom_chars(B,BC),
 append(BC,AC,BAC),
 split3(AC,BAC,ABAC),
 split2(AC,ABAC,C).

split3(AC,BAC,NewABAC):-
 append(AC,ABAC,BAC),split3(AC,ABAC,NewABAC).
split3(_,ABAC,ABAC).

split2(_,[],[]).
split2(X,Y,[A|O]):- 
 append(Z,X,ZX),append(ZX,R,Y),atom_chars(A,Z),
 split3(X,R,NewR),
 split2(X,NewR,O).

for example:

?- split(ab,ababxxabaabxxabxx,X).

X = [xx, a, xx, xx] 

Yes
?- split(ab,ababxxabaabxxabxx,X).

X = [xx, a, xx, xx] 

Yes
?- split(a,aaxxaaaxxaxx,X).

X = [xx, xx, xx] 

Yes
?- split(a,axxaaaxxaxx,X).

X = [xx, xx, xx] 

Yes
?- 




> ----------
> From: 	Alfonso Ortega de la Puente
> Sent: 	Wednesday, November 03, 1999 17:41
> To: 	'Luis Iraola Moreno'; Joakim Vrblom
> Cc: 	prolog@swi.psy.uva.nl
> Subject: 	RE: split/3
> 
> 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/
> 
> 
> 
> ----------------
> * 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/
> 

