MathGroup Archive 2010

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

Search the Archive

Named patterns forbidden in Except?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110435] Named patterns forbidden in Except?
  • From: cca at gregosetroianos.mat.br
  • Date: Fri, 18 Jun 2010 01:24:24 -0400 (EDT)

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?

Recently, during a course of mine (on Mathematica), I needed to illustrate
the concept of function as a set of ordered pairs. I had the following
definiton(inter alia):

FunctionQ[f_] := MatchQ[f, {{_, _} ...}] &&
      ! MatchQ[f, {___, {x_, _}, ___, {x_, _}, ___}]

Then it occurred to me to use Except with two arguments just to give it a
chance to shine in the course:

(*doesn=B4t work!*)
FunctionQ[f_] :=
 MatchQ[f, Except[{___, {x_, _}, ___, {x_, _}, ___}, {{_, _} ...}]]

Wouldn't this be simpler and natural? I would much appreciate any
explanation...

Atenciosamente,

Carlos C=E9sar de Ara=FAjo
Gregos & Troianos Educacional
www.gregosetroianos.mat.br
Belo Horizonte, MG, Brasil
(31) 3283-1122


  • Prev by Date: Re: Difficulty with saving Package .m files
  • Next by Date: Compiled function not working
  • Previous by thread: Floating point exception when taking a reciprocal of a list in v.
  • Next by thread: Re: Named patterns forbidden in Except?