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

Look at the DownValues of f to see how Mathematica will proceed:

DownValues[f]
{HoldPattern[f[{a_, b_}]] :> a, HoldPattern[f[a_]] :> a}

OR

?f

Mathematica graphics

So, though you defined f[a_] := a first, the other definition is more specific, hence is applied first. If Mathematica cannot decide it will use the definitions in the order they were entered.


From the documentation:

The transformation rules associated with a particular symbol s are always stored in a definite order, and are tested in that order when they are used. Each time you make an assignment, the corresponding transformation rule is inserted at the end of the list of transformation rules associated with s, except in the following cases:

  • The left‐hand side of the transformation rule is identical to a transformation rule that has already been stored, and any conditions on the right‐hand side are also identical. In this case, the new transformation rule is inserted in place of the old one.

  • The Wolfram Language determines that the new transformation rule is more specific than a rule already present, and would never be used if it were placed after this rule. In this case, the new rule is placed before the old one. Note that in many cases it is not possible to determine whether one rule is more specific than another; in such cases, the new rule is always inserted at the end.

However this doesn't appear to be quite the whole story. See:

And also

Look at the DownValues of f to see how Mathematica will proceed:

DownValues[f]
{HoldPattern[f[{a_, b_}]] :> a, HoldPattern[f[a_]] :> a}

OR

?f

Mathematica graphics

So, though you defined f[a_] := a first, the other definition is more specific, hence is applied first. If Mathematica cannot decide it will use the definitions in the order they were entered.


From the documentation:

The transformation rules associated with a particular symbol s are always stored in a definite order, and are tested in that order when they are used. Each time you make an assignment, the corresponding transformation rule is inserted at the end of the list of transformation rules associated with s, except in the following cases:

  • The left‐hand side of the transformation rule is identical to a transformation rule that has already been stored, and any conditions on the right‐hand side are also identical. In this case, the new transformation rule is inserted in place of the old one.

  • The Wolfram Language determines that the new transformation rule is more specific than a rule already present, and would never be used if it were placed after this rule. In this case, the new rule is placed before the old one. Note that in many cases it is not possible to determine whether one rule is more specific than another; in such cases, the new rule is always inserted at the end.

However this doesn't appear to be quite the whole story. See:

And also

Look at the DownValues of f to see how Mathematica will proceed:

DownValues[f]
{HoldPattern[f[{a_, b_}]] :> a, HoldPattern[f[a_]] :> a}

OR

?f

Mathematica graphics

So, though you defined f[a_] := a first, the other definition is more specific, hence is applied first. If Mathematica cannot decide it will use the definitions in the order they were entered.


From the documentation:

The transformation rules associated with a particular symbol s are always stored in a definite order, and are tested in that order when they are used. Each time you make an assignment, the corresponding transformation rule is inserted at the end of the list of transformation rules associated with s, except in the following cases:

  • The left‐hand side of the transformation rule is identical to a transformation rule that has already been stored, and any conditions on the right‐hand side are also identical. In this case, the new transformation rule is inserted in place of the old one.

  • The Wolfram Language determines that the new transformation rule is more specific than a rule already present, and would never be used if it were placed after this rule. In this case, the new rule is placed before the old one. Note that in many cases it is not possible to determine whether one rule is more specific than another; in such cases, the new rule is always inserted at the end.

However this doesn't appear to be quite the whole story. See:

And also

added 136 characters in body
Source Link
RunnyKine
  • 33.3k
  • 3
  • 110
  • 176

Look at the DownValues of f to see how Mathematica will proceed:

DownValues[f]
{HoldPattern[f[{a_, b_}]] :> a, HoldPattern[f[a_]] :> a}

OR

?f

Mathematica graphics

So, though you defined f[a_] := a first, the other definition is more specific, hence is applied first. If Mathematica cannot decide it will use the definitions in the order they were entered.


From the documentation:

The transformation rules associated with a particular symbol s are always stored in a definite order, and are tested in that order when they are used. Each time you make an assignment, the corresponding transformation rule is inserted at the end of the list of transformation rules associated with s, except in the following cases:

  • The left‐hand side of the transformation rule is identical to a transformation rule that has already been stored, and any conditions on the right‐hand side are also identical. In this case, the new transformation rule is inserted in place of the old one.

  • The Wolfram Language determines that the new transformation rule is more specific than a rule already present, and would never be used if it were placed after this rule. In this case, the new rule is placed before the old one. Note that in many cases it is not possible to determine whether one rule is more specific than another; in such cases, the new rule is always inserted at the end.

However this doesn't appear to be quite the whole story. See:

And also

Look at the DownValues of f to see how Mathematica will proceed:

DownValues[f]
{HoldPattern[f[{a_, b_}]] :> a, HoldPattern[f[a_]] :> a}

OR

?f

Mathematica graphics

So, though you defined f[a_] := a first, the other definition is more specific, hence is applied first. If Mathematica cannot decide it will use the definitions in the order they were entered.


From the documentation:

The transformation rules associated with a particular symbol s are always stored in a definite order, and are tested in that order when they are used. Each time you make an assignment, the corresponding transformation rule is inserted at the end of the list of transformation rules associated with s, except in the following cases:

  • The left‐hand side of the transformation rule is identical to a transformation rule that has already been stored, and any conditions on the right‐hand side are also identical. In this case, the new transformation rule is inserted in place of the old one.

  • The Wolfram Language determines that the new transformation rule is more specific than a rule already present, and would never be used if it were placed after this rule. In this case, the new rule is placed before the old one. Note that in many cases it is not possible to determine whether one rule is more specific than another; in such cases, the new rule is always inserted at the end.

However this doesn't appear to be quite the whole story. See:

Look at the DownValues of f to see how Mathematica will proceed:

DownValues[f]
{HoldPattern[f[{a_, b_}]] :> a, HoldPattern[f[a_]] :> a}

OR

?f

Mathematica graphics

So, though you defined f[a_] := a first, the other definition is more specific, hence is applied first. If Mathematica cannot decide it will use the definitions in the order they were entered.


From the documentation:

The transformation rules associated with a particular symbol s are always stored in a definite order, and are tested in that order when they are used. Each time you make an assignment, the corresponding transformation rule is inserted at the end of the list of transformation rules associated with s, except in the following cases:

  • The left‐hand side of the transformation rule is identical to a transformation rule that has already been stored, and any conditions on the right‐hand side are also identical. In this case, the new transformation rule is inserted in place of the old one.

  • The Wolfram Language determines that the new transformation rule is more specific than a rule already present, and would never be used if it were placed after this rule. In this case, the new rule is placed before the old one. Note that in many cases it is not possible to determine whether one rule is more specific than another; in such cases, the new rule is always inserted at the end.

However this doesn't appear to be quite the whole story. See:

And also

added 1290 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

Look at the DownValues of f to see how Mathematica will proceed:

DownValues[f]
{HoldPattern[f[{a_, b_}]] :> a, HoldPattern[f[a_]] :> a}

OR

?f

Mathematica graphics

So, though you defined f[a_] := a first, the other definition is more specific, hence is applied first. If Mathematica cannot decide it will use the definitions in the order they were entered.


From the documentation:

The transformation rules associated with a particular symbol s are always stored in a definite order, and are tested in that order when they are used. Each time you make an assignment, the corresponding transformation rule is inserted at the end of the list of transformation rules associated with s, except in the following cases:

  • The left‐hand side of the transformation rule is identical to a transformation rule that has already been stored, and any conditions on the right‐hand side are also identical. In this case, the new transformation rule is inserted in place of the old one.

  • The Wolfram Language determines that the new transformation rule is more specific than a rule already present, and would never be used if it were placed after this rule. In this case, the new rule is placed before the old one. Note that in many cases it is not possible to determine whether one rule is more specific than another; in such cases, the new rule is always inserted at the end.

However this doesn't appear to be quite the whole story. See:

Look at the DownValues of f to see how Mathematica will proceed:

DownValues[f]
{HoldPattern[f[{a_, b_}]] :> a, HoldPattern[f[a_]] :> a}

OR

?f

Mathematica graphics

So, though you defined f[a_] := a first, the other definition is more specific, hence is applied first. If Mathematica cannot decide it will use the definitions in the order they were entered.

Look at the DownValues of f to see how Mathematica will proceed:

DownValues[f]
{HoldPattern[f[{a_, b_}]] :> a, HoldPattern[f[a_]] :> a}

OR

?f

Mathematica graphics

So, though you defined f[a_] := a first, the other definition is more specific, hence is applied first. If Mathematica cannot decide it will use the definitions in the order they were entered.


From the documentation:

The transformation rules associated with a particular symbol s are always stored in a definite order, and are tested in that order when they are used. Each time you make an assignment, the corresponding transformation rule is inserted at the end of the list of transformation rules associated with s, except in the following cases:

  • The left‐hand side of the transformation rule is identical to a transformation rule that has already been stored, and any conditions on the right‐hand side are also identical. In this case, the new transformation rule is inserted in place of the old one.

  • The Wolfram Language determines that the new transformation rule is more specific than a rule already present, and would never be used if it were placed after this rule. In this case, the new rule is placed before the old one. Note that in many cases it is not possible to determine whether one rule is more specific than another; in such cases, the new rule is always inserted at the end.

However this doesn't appear to be quite the whole story. See:

deleted 3 characters in body
Source Link
RunnyKine
  • 33.3k
  • 3
  • 110
  • 176
Loading
Source Link
RunnyKine
  • 33.3k
  • 3
  • 110
  • 176
Loading