Question
I would like to know if it is possible to have a named pattern within a repeated pattern during function desctiption. For example: f[(a_)..]:=
Why I am asking
I am trying to accept a single association as an argument and collect all keys into one list and all values into another list named keys and values respectively. I would like to do all of this during function construction.
My Attempt
Expected Input
f[<|(keys_->values_)..|>]:={keys, values}
f[<|key1->value1,key2->value2|>
Expected Output
{{key1, key2},{value1,value2}}
Similar Questions
I found one similar question called Naming Repeated Patterns. However, this question is about naming the repeated portion x:(_->_)..
rather than the part within the repeated portion (k_->v_)..
f[(a_)..]:=
works just fine; tryf[(a_) ..] := {a}
followed byf[1,1,1,1]
. But it does not do what you want with the association, nor should it. You can dof[ass_Association] := With[{keys = Keys[ass], values = Values[ass]}, ...]
which works just as well though. $\endgroup$assoc_
I think, "dammit, I'm an adult and I can swear in my code if I want to" $\endgroup$