Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9666 > unrolled thread

Understanding patterns

Started bySam Takoy <sam.takoy@yahoo.com>
First post2012-04-16 10:12 +0000
Last post2012-04-18 07:52 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Understanding patterns Sam Takoy <sam.takoy@yahoo.com> - 2012-04-16 10:12 +0000
    Re: Understanding patterns Simon <simonjtyler@gmail.com> - 2012-04-18 07:52 +0000

#9666 — Understanding patterns

FromSam Takoy <sam.takoy@yahoo.com>
Date2012-04-16 10:12 +0000
SubjectUnderstanding patterns
Message-ID<jmgra7$pm5$1@smc.vnet.net>
Hi,

I hoping to get some pointers on understanding patterns. For example,
I can't quite make sense of the following:

f[p : {__?NumericQ}] :=

What is the meaning of "{", the double underscore, and the question
mark?

Many thanks in advance,

Sam

[toc] | [next] | [standalone]


#9690

FromSimon <simonjtyler@gmail.com>
Date2012-04-18 07:52 +0000
Message-ID<jmlrsi$jbv$1@smc.vnet.net>
In reply to#9666
> I can't quite make sense of the following:
> 
> f[p : {__?NumericQ}] :=

The other replies have already described what the pattern does. I thought it might just be useful to point out that you can also examine the FullForm structure: 
In[]:= FullForm[p:{__?NumericQ}]
Out[]= Pattern[p, List[PatternTest[BlankSequence[], NumericQ]]] 

Sometimes when constructing complicated patterns with defaults etc, I find it useful to look at the FullForm...

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web