Skip to main content

Timeline for How to speed up pattern matching

Current License: CC BY-SA 3.0

6 events
when toggle format what by license comment
Aug 2, 2016 at 1:22 comment added Wjx Check @Mr.Wizard 's update~
Aug 1, 2016 at 15:26 comment added Michael E2 @Wjx I don't understand your simple alternation. Cases[{{1}}, a_ /; MatchQ[a, {x__?((...; Return[False, MatchQ])&), z__}]]? Or perhaps you could clarify what you do want? (I can't fix something that's working on the example problem, obviously.)
Aug 1, 2016 at 14:58 comment added Wjx I'll have to say that this answer will do the job, but only for my far too simple illustrative code, instead of pattern matching in general. A simple alternation from MatchQ to Cases and return False only when inputing 1 will make this kind of solution fail. Its implementation is too narrow, actually not quite what I want.
Aug 1, 2016 at 14:18 history edited Michael E2 CC BY-SA 3.0
Added alternative
Aug 1, 2016 at 14:15 comment added Michael E2 The logic of this use-case is simple enough to allow this simple optimization. One can imagine a more general question of how to find the optimal check on a given pattern. My feeling is that is impractical to solve. But one might be able to apply code-optimization techniques to the problem.
Aug 1, 2016 at 14:08 history answered Michael E2 CC BY-SA 3.0