Re: Why () around Function in pattern?
- To: mathgroup at smc.vnet.net
- Subject: [mg16430] Re: Why () around Function in pattern?
- From: Hartmut Wolf <hw at gsmail01.darmstadt.dsh.de>
- Date: Sat, 13 Mar 1999 02:21:43 -0500
- Organization: debis Systemhaus
- References: <7c59uk$7of@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Dear Kevin,
Kevin Jaffe schrieb:
>
> Why does this "work"
>
> In[172]:= q[{x_Integer, y_Integer} ?
> (Function[v, v.v > 4])] := qp[x + y]
> In[173]:= q[{3, 4}]
> Out[173]= qp[7]
>
> while this doesn't?:
>
> In[174]:= qq[{x_Integer, y_Integer} ?
> Function[v, v.v > 4]] := qp[x + y]
> In[175]:= qq[{3, 4}]
> Out[175]= qq[{3, 4}]
>
> I.e., why are ()'s necessary around the pure function
> in the arguments pattern?
>
look at:
In[54]:=pattern?(Function[v,v.v>4])//FullForm
Out[54]//FullForm=
PatternTest[pattern,Function[v,Greater[Dot[v,v],4]]]
In[55]:=
pattern?Function[v,v.v>4]//FullForm
Out[55]//FullForm=
PatternTest[pattern,Function][v,Greater[Dot[v,v],4]]
So as S.Wolfram states in his book:
pattern?test
has a higher priority than
expr1[expr2, ...]
---Hartmut