MathGroup Archive 2007

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

Search the Archive

Re: problem with Pick


On 25 Jun 2007, at 20:06, Chris Chiasson wrote:

> Step to reproduce:
> 1. Evaluate these two inputs with a fresh kernel:
> Pick[{a,b},z[{},{1}],{__}]
> In[78]:= Pick[{a, b}, {{}, {1}}, {__Integer}]
> Out[78]= {b}
>
> Expected results:
> {b}
> {b}
>
> Actual results:
> {b}
> {a,b}
>
> Relevant Documentation:
> Pick[list,sel,patt] picks out those list[[i1,i2,...]] for which
> sel[[i1,i2,...]] matches patt.
>
> Relevant Evaluation:
> In[3]:= MatchQ[{},{__}]
> Out[3]= False
>
> In[4]:= {Internal`$CreationID,$Version}
> Out[4]= {853857,6.0 for Microsoft Windows (32-bit) (April 27, 2007)}
>
> --
> http://chris.chiasson.name/
>


But of course

MatchQ[{{}, {1}}, {__}]
  True

In other words, there is a Match at the top level in exactly the same  
way as here:

Pick[{a, b}, {}, {___}]
{a, b}


You can avoid the top level match, by using, for example,

Pick[{a, b}, {{}, {1}}, {__Integer}]
{b}

Andrzej Kozlowski


  • Prev by Date: Re: problem with Pick
  • Next by Date: Re: problem with Pick
  • Previous by thread: Re: problem with Pick
  • Next by thread: Re: problem with Pick