I am trying to write a function with a pattern that tests its arguments for a particular structure. But in that pattern I'd like to name a subpattern to make it easier to exract and operate on.
The code below works fine:
Plant[x:Allele[_,_]..] := Involute[{x}]
But what I really want is to extract the parts of each Allele expression and pass them as lists to Involute. I tried using the definition below (expecting a
and b
to be Sequences of the arguments to Allele):
Plant[x:Allele[a_,b_]..] := Involute[{x}, {a}, {b}]
Unfortunately, this produces unexpected results when evaluated - specifically it only seems to work on expressions that accept a single Allele argument. When a expand the pattern I get:
In: (x:Allele[a_,b_]..)//FullForm
Out: Pattern[x, Repeated[Allele[Pattern[a, Blank[]], Pattern[b, Blank[]]]]]
which doesn't seem right. Where's the mistake?