MathGroup Archive 2012

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

Search the Archive

Re: How to use Pick[]; Is this a bug?


Appears to be a bug.

list = Range[5];

sel = {9, 0, 7, 0, 6};

Here are a few workarounds:

Pick[list, # != 0 & /@ sel]

{1, 3, 5}

Pick[list, sel, _?(# != 0 &)]

{1, 3, 5}


Bob Hanlon


On Tue, Aug 14, 2012 at 4:22 AM,  <benp84 at gmail.com> wrote:
> In[1]:=  Pick[{1, 2, 3, 4, 5}, {9, 0, 7, 0, 6}, Except[0]]
> Out[1]:= {1, 2, 3, 4, 5}
>
> Shouldn't this return {1, 3, 5}, since these are the corresponding elements that match Except[0]?
>



  • Prev by Date: Re: Find Position of many elements in a large list.
  • Next by Date: Re: Find Position of many elements in a large list.
  • Previous by thread: How to use Pick[]; Is this a bug?
  • Next by thread: Re: How to use Pick[]; Is this a bug?