Timeline for How to use Optional as an omissible parameter in pattern-match?
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 10, 2012 at 15:22 | history | edited | Jens | CC BY-SA 3.0 |
Corrected according to @kguler's answer
|
Dec 10, 2012 at 15:21 | comment | added | Jens |
Oh yes, you need both patterns as @kguler observed. I got True everywhere because I must have not exectuted the Clear so I did have both your and my definitions.
|
|
Dec 10, 2012 at 13:45 | comment | added | Mr.Wizard |
MatchQ[list, {__Integer}] is much faster than And @@ IntegerQ /@ list to check for a list of Integers. @ywdr1987 CoefficientList[#, x] ~MatchQ~ {__Integer} & /@ {x, 2 x, 2 x + 1, 2 x^2 + 3 x, 2 x^2 + 3 x + 1} returns {True, True, True, True, True} here.
|
|
Dec 10, 2012 at 11:24 | comment | added | ywdr1987 |
With your definition of intPolyQ , it turns out that intPolyQ[#, x] & /@ {x, 2 x, 2 x + 1, 2 x^2 + 3 x, 2 x^2 + 3 x + 1} returns {False, False, False, True, False} in my computer! What's wrong!? @Jens
|
|
Dec 10, 2012 at 11:07 | vote | accept | ywdr1987 | ||
Dec 10, 2012 at 11:15 | |||||
Dec 10, 2012 at 10:48 | vote | accept | ywdr1987 | ||
Dec 10, 2012 at 10:48 | |||||
Dec 10, 2012 at 7:43 | history | answered | Jens | CC BY-SA 3.0 |