Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Pattern: x_List with conditions on elements

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110850] Re: Pattern: x_List with conditions on elements
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Thu, 8 Jul 2010 07:40:50 -0400 (EDT)
  • References: <201007080713.DAA07725@smc.vnet.net>

Hi Ryan,

1. How about this:

MatchQ[{1, 2, 2.2}, _?(MatchQ[N[#],  { ___Real}] &)]

2. { ___Symbol}

3. Sounds like a good idea, but the hardest part will be to categorize them
so that they can be searched efficiently. Some kind of tagging system may be
needed for that.

Regards,
Leonid

On Thu, Jul 8, 2010 at 11:13 AM, telefunkenvf14 <rgorka at gmail.com> wrote:

> Group:
>
> 1. Can someone provide a clearer way of implementing the following
> example? (Goal: I want a pattern that accepts only a list of real
> numbers and what I have seems hacky.)
>
> MatchQ[{1, 2, 2.2},x_?(VectorQ[#,(NumericQ[#]&&Im[#]==0)&]&)]
>
> 2. Could someone show me how to create a second pattern which accepts
> only a list (vector) of symbols? I feel like I'm spinning my wheels a
> bit on this one...
>
> 3. Does anyone else think it would be nice to compile a list of
> favorite/useful patterns, along with a very brief explanation of the
> intent? (And yes, I know there are a bunch of examples in the
> documentation(!), but I'm thinking more in terms of assembling a list
> of recipes.) I guess I'm just craving more guided examples.
>
> -RG
>
>
>


  • Prev by Date: Re: First nonzero in list
  • Next by Date: Re: replacement x->y except in Exp[x]
  • Previous by thread: Re: Pattern: x_List with conditions on elements
  • Next by thread: Re: Pattern: x_List with conditions on elements