RE: a question about pattern replacements
- To: mathgroup at smc.vnet.net
- Subject: [mg36170] RE: [mg36163] a question about pattern replacements
- From: "David Park" <djmp at earthlink.net>
- Date: Mon, 26 Aug 2002 04:15:47 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Sidney, With a direct rule Mathematica tries to Flatten the symbol q immediately. You want a delayed rule to avoid the error message. z /. SomeHead[q_] :> Flatten[q] David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Sidney Cadot [mailto:sidney at jigsaw.nl] To: mathgroup at smc.vnet.net Hi all, While playing arounf with patterns and substitutions, I came across the following behavior which I didn't expect: z := SomeHead[{{1, 2}, {3, 4}}] z /. {SomeHead[q_] -> Flatten[q]} While this _does_ yield the desired result {1,2,3,4}, Mathematica complains: Flatten::"normal": Nonatomic expression expected at position 1 in Flatten[q]. ........as if it is trying to evaluate Flatten[q], with q not bound to {{1,2},{3,4}}. Could anybody explain why this happens? Best regards, Sidney Cadot