MathGroup Archive 2005

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

Search the Archive

Re: logical indexing using more than one variable in a pure function


This is one possible solution :

In[1]:=
myPick[y1_List,y2_List,cond_[y1_List,y2_List]]:=
Select[Transpose[{y1,y2}],cond[#[[1]],#[[2]]]&][[All,1]];
myPick[y1_List,y2_List,cond_[y2_List,y1_List]]:=
Select[Transpose[{y1,y2}],cond[#[[2]],#[[1]]]&][[All,1]];

In[3]:=
x1={2,3,4,5,6};
x2={6,5,4,3,2};

In[5]:=
myPick[x1,x2,x1>x2]

Out[5]=
{5,6}

In[6]:=
myPick[x1,x2,x2<=x1]

Out[6]=
{4,5,6}


hth

Valeri


  • Prev by Date: Export Animation
  • Next by Date: Special Prime Product
  • Previous by thread: Re: logical indexing using more than one variable in a pure function
  • Next by thread: Re: logical indexing using more than one variable in a pure function