Skip to main content

Timeline for How to make a pattern to match?

Current License: CC BY-SA 3.0

5 events
when toggle format what by license comment
Sep 19, 2016 at 19:01 comment added Bob Hanlon @Mr.Wizard - edited per your recommendation. Thanks.
Sep 19, 2016 at 18:58 history edited Bob Hanlon CC BY-SA 3.0
Per Mr. Wizard's recommendation, added additional checks
Sep 19, 2016 at 10:49 comment added Michael E2 An alternative one might use is MatchQ[#[[position]], val] instead of #[[position]] == val, and then val could be any pattern. One should beware that with ==, elements will match that are sufficiently close numerically to be considered equal, whereas with MatchQ, they have to be exactly the same. So == will be a superior approach in some applications and not in others.
Sep 19, 2016 at 9:46 comment added Mr.Wizard This is the method I typically use, however consider adding a Length check to avoid e.g. {1, 2}[[3]], i.e. Length[#] >= position && #[[position]] == val
Sep 18, 2016 at 22:24 history answered Bob Hanlon CC BY-SA 3.0