Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

I think my answer to Why does this pattern with Plus not work for numbers?Why does this pattern with Plus not work for numbers? is also the answer here.


See Plus in the reference manual:

Unlike other functions, Plus applies built-in rules before user-defined ones. As a result, it is not possible to make definitions such as 2+2=5.

The ability for user-defined rules to supersede built-in ones was lost in Version 3.


There is a similar property for Times.

Here is some evidence that rules for Plus are applied internally even when Plus is blocked:

Block[{Plus}, 1 + 2*2 /. Plus -> List]
(*  5  *)

p[x__] := Plus[x];
Block[{p}, p[1, 2*2] /. p -> List]
(*  {1, 4}  *)

Update -- some more evidence:

Block[{Plus}, 
  Hold[1 + 2*2] /. x_Plus :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

Block[{p}, 
  Hold[p[1, 2*2]] /. x_p :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

I think my answer to Why does this pattern with Plus not work for numbers? is also the answer here.


See Plus in the reference manual:

Unlike other functions, Plus applies built-in rules before user-defined ones. As a result, it is not possible to make definitions such as 2+2=5.

The ability for user-defined rules to supersede built-in ones was lost in Version 3.


There is a similar property for Times.

Here is some evidence that rules for Plus are applied internally even when Plus is blocked:

Block[{Plus}, 1 + 2*2 /. Plus -> List]
(*  5  *)

p[x__] := Plus[x];
Block[{p}, p[1, 2*2] /. p -> List]
(*  {1, 4}  *)

Update -- some more evidence:

Block[{Plus}, 
  Hold[1 + 2*2] /. x_Plus :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

Block[{p}, 
  Hold[p[1, 2*2]] /. x_p :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

I think my answer to Why does this pattern with Plus not work for numbers? is also the answer here.


See Plus in the reference manual:

Unlike other functions, Plus applies built-in rules before user-defined ones. As a result, it is not possible to make definitions such as 2+2=5.

The ability for user-defined rules to supersede built-in ones was lost in Version 3.


There is a similar property for Times.

Here is some evidence that rules for Plus are applied internally even when Plus is blocked:

Block[{Plus}, 1 + 2*2 /. Plus -> List]
(*  5  *)

p[x__] := Plus[x];
Block[{p}, p[1, 2*2] /. p -> List]
(*  {1, 4}  *)

Update -- some more evidence:

Block[{Plus}, 
  Hold[1 + 2*2] /. x_Plus :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

Block[{p}, 
  Hold[p[1, 2*2]] /. x_p :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

Fixed link
Source Link
Michael E2
  • 244.8k
  • 18
  • 351
  • 774

I think my answer to Block attributes of EqualWhy does this pattern with Plus not work for numbers? is also the answer here.


See Plus in the reference manual:

Unlike other functions, Plus applies built-in rules before user-defined ones. As a result, it is not possible to make definitions such as 2+2=5.

The ability for user-defined rules to supersede built-in ones was lost in Version 3.


There is a similar property for Times.

Here is some evidence that rules for Plus are applied internally even when Plus is blocked:

Block[{Plus}, 1 + 2*2 /. Plus -> List]
(*  5  *)

p[x__] := Plus[x];
Block[{p}, p[1, 2*2] /. p -> List]
(*  {1, 4}  *)

Update -- some more evidence:

Block[{Plus}, 
  Hold[1 + 2*2] /. x_Plus :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

Block[{p}, 
  Hold[p[1, 2*2]] /. x_p :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

I think my answer to Block attributes of Equal is also the answer here.


See Plus in the reference manual:

Unlike other functions, Plus applies built-in rules before user-defined ones. As a result, it is not possible to make definitions such as 2+2=5.

The ability for user-defined rules to supersede built-in ones was lost in Version 3.


There is a similar property for Times.

Here is some evidence that rules for Plus are applied internally even when Plus is blocked:

Block[{Plus}, 1 + 2*2 /. Plus -> List]
(*  5  *)

p[x__] := Plus[x];
Block[{p}, p[1, 2*2] /. p -> List]
(*  {1, 4}  *)

Update -- some more evidence:

Block[{Plus}, 
  Hold[1 + 2*2] /. x_Plus :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

Block[{p}, 
  Hold[p[1, 2*2]] /. x_p :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

I think my answer to Why does this pattern with Plus not work for numbers? is also the answer here.


See Plus in the reference manual:

Unlike other functions, Plus applies built-in rules before user-defined ones. As a result, it is not possible to make definitions such as 2+2=5.

The ability for user-defined rules to supersede built-in ones was lost in Version 3.


There is a similar property for Times.

Here is some evidence that rules for Plus are applied internally even when Plus is blocked:

Block[{Plus}, 1 + 2*2 /. Plus -> List]
(*  5  *)

p[x__] := Plus[x];
Block[{p}, p[1, 2*2] /. p -> List]
(*  {1, 4}  *)

Update -- some more evidence:

Block[{Plus}, 
  Hold[1 + 2*2] /. x_Plus :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

Block[{p}, 
  Hold[p[1, 2*2]] /. x_p :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

added 343 characters in body
Source Link
Michael E2
  • 244.8k
  • 18
  • 351
  • 774

I think my answer to Block attributes of Equal is also the answer here.


See Plus in the reference manual:

Unlike other functions, Plus applies built-in rules before user-defined ones. As a result, it is not possible to make definitions such as 2+2=5.

The ability for user-defined rules to supersede built-in ones was lost in Version 3.


There is a similar property for Times.

Here is some evidence that rules for Plus are applied internally even when Plus is blocked:

Block[{Plus}, 1 + 2*2 /. Plus -> List]
(*  5  *)

p[x__] := Plus[x];
Block[{p}, p[1, 2*2] /. p -> List]
(*  {1, 4}  *)

Update -- some more evidence:

Block[{Plus}, 
  Hold[1 + 2*2] /. x_Plus :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

Block[{p}, 
  Hold[p[1, 2*2]] /. x_p :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

I think my answer to Block attributes of Equal is also the answer here.


See Plus in the reference manual:

Unlike other functions, Plus applies built-in rules before user-defined ones. As a result, it is not possible to make definitions such as 2+2=5.

The ability for user-defined rules to supersede built-in ones was lost in Version 3.


There is a similar property for Times.

Here is some evidence that rules for Plus are applied internally even when Plus is blocked:

Block[{Plus}, 1 + 2*2 /. Plus -> List]
(*  5  *)

p[x__] := Plus[x];
Block[{p}, p[1, 2*2] /. p -> List]
(*  {1, 4}  *)

I think my answer to Block attributes of Equal is also the answer here.


See Plus in the reference manual:

Unlike other functions, Plus applies built-in rules before user-defined ones. As a result, it is not possible to make definitions such as 2+2=5.

The ability for user-defined rules to supersede built-in ones was lost in Version 3.


There is a similar property for Times.

Here is some evidence that rules for Plus are applied internally even when Plus is blocked:

Block[{Plus}, 1 + 2*2 /. Plus -> List]
(*  5  *)

p[x__] := Plus[x];
Block[{p}, p[1, 2*2] /. p -> List]
(*  {1, 4}  *)

Update -- some more evidence:

Block[{Plus}, 
  Hold[1 + 2*2] /. x_Plus :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

Block[{p}, 
  Hold[p[1, 2*2]] /. x_p :> With[{r = x}, r /; True]] // Trace

Mathematica graphics

Post Undeleted by Michael E2
Post Deleted by Michael E2
Source Link
Michael E2
  • 244.8k
  • 18
  • 351
  • 774
Loading