MathGroup Archive 2010

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

Search the Archive

Re: Named patterns forbidden in Except?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110483] Re: Named patterns forbidden in Except?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 20 Jun 2010 03:46:43 -0400 (EDT)

There are multiple ways to get the intended result:

DeleteCases[{-0.5, 1, -3, 2/5, I}, _Integer]

{-0.5, 2/5, I}

Select[{-0.5, 1, -3, 2/5, I}, ! IntegerQ[#] &]

{-0.5, 2/5, I}

Cases[{-0.5, 1, -3, 2/5, I}, _?(! IntegerQ[#] &)]

{-0.5, 2/5, I}


Bob Hanlon

---- David Bailey <dave at removedbailey.co.uk> wrote: 

=============
On 18/06/10 06:25, cca at gregosetroianos.mat.br wrote:
> Hi,
>
> Consider this:
>
> In[1]:= Cases[{-0.5, 1, -3, 2/5, I}, Except[x_Integer]]
>
> During evaluation of In[1]:= Except::named: Named pattern variables are not
> allowed in the first argument of Except[x_Integer].>>
>
> Out[1]= {}
>
> Why are named patterns not allowed in Except?
>


I guess the point is that you could never use the name - because in your 
example, if x took a value, Except would fail to match by definition!

David Bailey

http://www.dbaileyconsultancy.co.uk




  • Prev by Date: Re: defining a function of functions
  • Next by Date: Re: defining a function of functions
  • Previous by thread: Re: Named patterns forbidden in Except?
  • Next by thread: Re: Named patterns forbidden in Except?