MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Pattern matching more than once

  • To:
  • Subject: [mg11991] Pattern matching more than once
  • From: (ASARI Hirotsugu)
  • Date: Fri, 17 Apr 1998 03:40:27 -0400
  • Organization: University of Illinois at Urbana-Champaign

I have been stuck with the following problem for about 10 days.  I can't
think of an elegant solution.

Input: Two lists, from some universal set Output: Many "spliced" lists
obtained from the input.

e.g.	{{a,b,c},{d,e,f}} --> {{a,b,c},{d,e,f}} (no common element)

	{{a,b,c},{d,b,f}} --> {{a,b,c},{d,b,f},{a,b,f},{d,b,c}}

	{{a,b,c,d,e},{f,b,g,d,h}} -->

I will regard the input as list of chains (totally ordered set) coming
from a partially ordered set, and I would like to extend these chains
as much as possible.  If there is at most one common element in the
inputs, the following will do:


The problem is that when the lists have more than one common element,
the second common element will not be considered at all.  I suppose I
could just write, for instance,

		 {pre2,x,mid1,y,post2},{pre2,x,mid2,y,post1}}]; But this is very ugly.

I suppose I could write some For[] loop through
Intersection[list1,list2], but I would rather avoid it if I could.

Any help would be appreciated.

ASARI Hirotsugu                 //
finger://   //    ph://
	"We are what we pretend to be, so we must be careful
		about what we pretend to be."	--Kurt Vonnegut

  • Prev by Date: Mathematica 3.0 FrontEnd
  • Next by Date: Output of Animate to AVI
  • Prev by thread: Mathematica 3.0 FrontEnd
  • Next by thread: Re: Pattern matching more than once