Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!lanl!opus!eiverson From: eiverson@nmsu.edu (Eric Iverson) Newsgroups: comp.lang.prolog Subject: Re: the great split up Message-ID: Date: 12 Feb 90 15:33:40 GMT References: <2858@goanna.oz.au> Sender: news@nmsu.edu Distribution: comp Organization: NMSU Computer Science Lines: 49 In-reply-to: ok@goanna.oz.au's message of 12 Feb 90 10:10:01 GMT In article <2858@goanna.oz.au> ok@goanna.oz.au (Richard O'keefe) writes: > After much puzzling, I finally decided that the intent is that > split(Cat, Str, A, B) > is to be true when Cat, Str, A, and B are all lists, and > there exist lists Alpha, Omega such that > (1) Str = Alpha @ Cat @ Omega > (2) A = Alpha @ take(floor(N/2), Cat) > (3) B = drop(floor(N/2), Cat) @ Omega > where @ is concatenation and take, drop are as in APL. > > The first observation is that this is a rather strange thing to do. > What is it to be used for? If we knew that, perhaps some other data > structure entirely might be a better choice. We might also know then > whether all of the logical results were needed or whether the first > would suffice (for example, it might be known that Cat occurs precisely > once in Str). Sorry for the confusion. Here's some data: | ?- split([c,d],[a,b,c,d,e,a,b,c,d,e,a,b,c],A,B). A = [a,b,c], B = [d,e,a,b,c,d,e,a,b,c] ; A = [a,b,c,d,e,a,b,c], B = [d,e,a,b,c] ; no | ?- split([c,d,e],[a,b,c,d,e,a,b,c,d,e,a,b,c],A,B). A = [a,b,c,d], B = [e,a,b,c,d,e,a,b,c] ; A = [a,b,c,d,e,a,b,c,d], B = [e,a,b,c] ; I just want the first string to find copies of itself in the second string and then split the second string at the center of that copy. Hope this clears things up. -- ------------------------------------------------------------------------ Another Gruntpig production, in association with the Rat Lab Steamworks. I want to kill everyone here with a cute colorful Hydrogen Bomb!! -Zippy the Pinhead