MathGroup Archive 2011

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

Search the Archive

Re: Problem combining patterns

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119271] Re: Problem combining patterns
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Sat, 28 May 2011 07:19:07 -0400 (EDT)

You can do

ClassPattern[] := _?(Length[#] === 1 &);

or

ClassPattern[] := _ [ _ ]

Regards,
Leonid


On Fri, May 27, 2011 at 2:12 PM, Rui <rui.rojo at gmail.com> wrote:

> Hey people.
> I want to have an expression that evaluates to a pattern. Imagine
> something simple
>
> ClassPattern[]:=HoldPattern[i_/;Length[i]===1];
> So far so good. But then I'd like to use it in compound expressions
> like
>
> MatchQ[{b[3], c[5]}, {ClassPattern[], ClassPattern[]}]
>
> When I do so, the label "i" inside the pattern is treated as the same
> in both ClassPatterns, so I get false. But I wanna get True in cases
> like the one before
>
> Any ideas?
>
>


  • Prev by Date: Re: NDSolve issues with initial and boundary conditions (corrected
  • Next by Date: How to output a superfunction from a function input in mathematica
  • Previous by thread: Problem combining patterns
  • Next by thread: Re: Problem combining patterns