10,894 reputation
12050
bio website
location
age 28
visits member for 1 year, 11 months
seen Mar 23 at 22:02

Jan
16
accepted Pattern matching a pattern with patterns
Jan
16
comment Pattern matching a pattern with patterns
I have submitted an answer based on your method which solves my problems an allows the definition of a pattern for patterns without introducing a new function to handle comparison. I feel it's bascially a small rewrite of your method (at least your input in chat), so if you would like to include it in your answer I'll delete mine.
Jan
16
answered Pattern matching a pattern with patterns
Jan
16
comment Pattern matching a pattern with patterns
The possible duplicate is not relevant to this. The question there was to for instance determine that a_Integer and b_Integer span the same space. Here I would like to for instance have a pattern that spiritually reads (a|b)_(Integer|List) So I have a pattern that I want to use on the structure of a different pattern. That being said. I do belive that you have a real solution in injecting Verbatim around pattern components rather than my attempt at removing and checking these components.
Jan
16
comment Pattern matching a pattern with patterns
@LeonidShifrin I disagree. You seemed to interpret my question correctly, only you didn't fully answer it and you had an initial error which prevented me from getting your method to work, so I posted my own. Mr. Wizard did misinterpret the question, however he seemed to have skipped the part of the question that said letting {f,x,y,g,h} take arbitrary values, and attempted to answer the question ignoring this part even after some effort on my part to clarify this for him. Having one answer that misinterprets the question is hardly makes it vague. I have attempted to clarify by restructuring.
Jan
16
revised Pattern matching a pattern with patterns
added 1021 characters in body
Jan
16
comment Pattern matching a pattern with patterns
@Mr.Wizard I'm using my "patterns for patterns" in things such as Cases, however I wouldn't call that transformations using the patterns. The question is really just about using pattern matching to match things that are themselves patterns.
Jan
16
comment Pattern matching a pattern with patterns
@Mr.Wizard in the 3'rd codebox. I write MatchQ[b, (a /. {HoldPattern -> hp_,...} /. {f -> f_,...}) /; And[hp === HoldPattern,...]] Now the "f-> f_" replaces the literal f with a pattern. The method goes, 1: break down all patterns, 2: inject new patterns; 3: Verify that all the structure of the broken down patterns is still correct.
Jan
16
comment Pattern matching a pattern with patterns
@Mr.Wizard I substitute the literals for patterns after "breaking apart" other patterns by switching out the heads Pattern, Blank and such.
Jan
16
revised Pattern matching a pattern with patterns
deleted 49 characters in body
Jan
16
comment Pattern matching a pattern with patterns
@LeonidShifrin My clearification has nothing to do with types, I just chose those, since they are the type of structure you will typically see in a Pattern. I'm editing to remove the unwanted connection.
Jan
16
comment Pattern matching a pattern with patterns
I have a problem with the serialization. It'll give the same for eg. a[b,c] and a[b@c], so your solution gives true when testing with a = HoldPattern[g[x_@y_, _, {1, 2}, q : {g_, h_}]] :> g[x] + h[y] and the same b.
Jan
16
revised Pattern matching a pattern with patterns
added 852 characters in body
Jan
16
comment Pattern matching a pattern with patterns
@Mr.Wizard I don't follow you, f and g are never considered the same. When matching the pattern f->f_ replaces the symbol f with a pattern that (maybe confusingly so) is called f. You could equally well write f->x_ and then have x match f and g in each respectively.
Jan
16
comment Pattern matching a pattern with patterns
It might be cleaner, but it won't work in general for searching through patterns, only those that happen to take the form of DelayedRules, unless I'm misunderstanding something? Also, how would you go about extracting elements using your method(see edit)?
Jan
16
revised Pattern matching a pattern with patterns
added 322 characters in body
Jan
16
comment Pattern matching a pattern with patterns
I'm not sure why you feel the need to explicitly split up into lhs/rhs. Why not just match the entire patterns?
Jan
16
answered Trig angles simplifying in worksheet
Jan
16
asked Pattern matching a pattern with patterns
Jan
15
comment Compiling LinearSolve[] or creating a compilable procedural version of it
@Jagra What I was asking was how it changes. You posted a constant matrix and a constant array. They per definition never change. If you could for instance provide a matrix on the form {{a,b},{0,4}} and say with a and b having different values. That would be a useful description. Just saying "the values within the matrix and vector change constantly" is not useful, how do they change, do they all change?, which ones change etc. This is the information needed in order to judge whether you just need a single solution or a complete framework like LAPACK.