Timeline for On the order of rules specification [duplicate]
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 30, 2023 at 14:44 | comment | added | user7427029 | @Shredderroy sometimes, you wrote f[x ;/ MatchQ, in other words: ;/ (not /; as defined here: reference.wolfram.com/language/ref/Condition.html) . Was it a typing mistake or does it make sense and I simply do not know the syntactical construct used? | |
Aug 27, 2014 at 22:30 | history | closed |
RunnyKine mfvonh Michael E2 Öskå Mr.Wizard |
Duplicate of Multiple down-values with exactly the same lefthand side, Which function definition is used to evaluate an expression that matches the lefthand side of more than one definition? | |
Aug 27, 2014 at 21:24 | comment | added | Michael E2 |
Also of interest: Needs["GeneralUtilities`"]; Information[GeneralUtilities`PatternOrder]
|
|
Aug 27, 2014 at 20:18 | comment | added | Simon Woods |
As I understand it, a pattern with a condition attached is considered more specific than one without, but in general there is no way to say that one condition test is more specific than another. How would you order x_/;blackbox1[x] and x_/;blackbox2[x] ?
|
|
Aug 27, 2014 at 19:17 | comment | added | Michael E2 | This tutorial is also relevant: The Ordering Of Definitions | |
Aug 27, 2014 at 19:12 | review | Close votes | |||
Aug 27, 2014 at 22:30 | |||||
Aug 27, 2014 at 19:04 | comment | added | Shredderroy |
@RunnyKine Thanks a lot for linking that answer. It has some very relevant information. @mfvonh That is what I thought, except that it seems to matter in my code whether I specify the 0 pattern first or second. Hence my confusion.
|
|
Aug 27, 2014 at 18:51 | comment | added | mfvonh |
The order in which you issue these definitions does not matter. Mathematica will apply the "most specific" rule that matches. The finer points of that can be tricky, but here x_ is the least specific and {_?NumericQ, 0} is more specific than {_?NumericQ, _?NumericQ} because the latter contains a wildcard for the second argument whereas the first does not.
|
|
Aug 27, 2014 at 18:47 | history | asked | Shredderroy | CC BY-SA 3.0 |