Mathematica 9 is now available
Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Flat, OneIdentity attributes

  • To: mathgroup at
  • Subject: [mg21633] Re: [mg21600] Flat, OneIdentity attributes
  • From: BobHanlon at
  • Date: Tue, 18 Jan 2000 02:35:18 -0500 (EST)
  • Sender: owner-wri-mathgroup at


Attributes[f] = {Flat};
f[2] /. f[n_Integer] :> n + 10


I cannot explain this behavior. Further, this is even more unusual

Attributes[f] = {Flat};
f[2] /. f[n_] :> n + 10

f[2] + 10

Mathematica appears to interpret the first case as  
f[2]/.f[n_Integer]:>(n+10)  and the second case as  (f[2]/.f[n_]:>n)+10

Bob Hanlon

In a message dated 1/17/2000 12:15:24 AM, ErsekTR at writes:

>For the most part I understand how Flat and OneIdentity are related and
>demonstrate this using Version 4 in the examples below.
>In the first example (f) has the attributes Flat and OneIdentity. 
>The pattern matcher treats f[a,2,3] as f[a,f[2,3]] then uses the 
>replacement rule and {1,{2,3}} is returned.
>In the next example the only attribute (f) has is Flat.
>In this case the pattern matcher treats f[1,2,3] as 
>f[f[1],f[f[2],f[3]]] then uses the replacement rule and 
>{f[1],{f[2],f[3]}} is returned.
>OneIdentity the pattern matcher doesn't wrap (f) around a single argument
>when it tries different ways of nesting (f).
>In the next example (f) has the attributes Flat, OneIdentity and the rule
>For reasons I can't understand the rule isn't used in the next example.
>anyone explain why?

  • Prev by Date: Re: Series expansion of ArcSin around 1
  • Next by Date: Re: Question:Polar Field Plot
  • Previous by thread: Re: Flat, OneIdentity attributes
  • Next by thread: Re: Flat, OneIdentity attributes