MathGroup Archive 2006

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

Search the Archive

Re: Re: Can anybody help?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63691] Re: [mg63671] Re: Can anybody help?
  • From: Pratik Desai <pdesai1 at umbc.edu>
  • Date: Tue, 10 Jan 2006 01:48:45 -0500 (EST)
  • References: <dpd7hj$qi2$1@smc.vnet.net> <dpdjn5$5gr$1@smc.vnet.net> <200601090949.EAA29692@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Peter Pein wrote:

>Ray Koopman schrieb:
>  
>
>>Kent Holing wrote:
>>
>>    
>>
>>>I have three vecors containg: v1, v2 and v3.
>>>v1 and v2 has the same length. v3 is shorter than v1.
>>>All elements of v3 is an element of v1.
>>>Need to have the corresponding v2 values corresponding to the v3 (= v1) value.
>>>Know that the elements of v1 and v3 are different. The elements of v2 do not need to different.
>>>Ex:
>>>v1={1,2,3,4,5,6,7,8,9}
>>>v2={10,11,12,22,32,42,53,63,73}
>>>v3={3,5,8}
>>>The corresponding v2 values are {11,32,63}
>>>It easy to write straightforward code to do this.
>>>But is it really a very elegant/short way (one-liner?) of doing this in Mathematica?
>>>Kent Holing
>>>      
>>>
>>Pick[v2,MemberQ[v3,#]&/@v1]
>>
>>    
>>
>The syntax of Pick allows Pick[v2, v1, #] & /@ v3 // Flatten, which I would 
>prefer, because it is less nested. But it's a matter of taste.
>
>Peter
>
>  
>
Here is my two cent worth as well

Extract[v2,#]&/@Intersection[v1,v3]

Pratik


  • Prev by Date: Re: NDSolve::ndsz question
  • Next by Date: TraceScan
  • Previous by thread: Re: Can anybody help?
  • Next by thread: Re: Can anybody help?