[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Array intersections



Robert Moss (mossrm@texaco.com) writes: 

> I'm sure there were some clever responses to this same question
> just a few months ago, but for the life of me I cannot recall
> what they were. Here's the question:
> 
> What is the most efficient way (using IDL, of course) to return 
> the index at which two arrays intersect? e.g.
> 
> 	a = [ 1B, 2B, 9B, 5B, 6B, 11B ]
> 	b = [ 5B, 6B ]
> 	idx = intersect( a, b )
> 	idx = 3
> 
> This is a highly simplified example, but the point is that I want
> a function that will accept two array inputs (byte arrays in my specific
> case) and return to me the index in array a where the subset b starts.
> 
> Refresh my memory, please.

You can find the clever responses on my web page at:

   http://www.dfanning.com/tips/set_operations.html

Cheers,

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/