Re: problem with Pick
- To: mathgroup at smc.vnet.net
- Subject: [mg78234] Re: [mg78194] problem with Pick
- From: "Chris Chiasson" <chris at chiasson.name>
- Date: Tue, 26 Jun 2007 04:36:56 -0400 (EDT)
- References: <acbec1a40706230431p4f1db9a9i4320680dda027396@mail.gmail.com>
I agree 100% with your assessment of what is probably happening, but I
also note that this is in violation of Pick's documentation. I also
think Pick's present behavior in this situation neither is nor should
be intended.
On 6/25/07, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote:
> *This message was transferred with a trial version of CommuniGate(tm) Pro*
>
> 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
>
--
http://chris.chiasson.name/