I would like to generate sets of replacement rules programatically for predefining some permutations. So a function
MakeRule[cycles_List (* permute cycles *), n_Integer (* rule length *)]`
called as
MakeRule[{{2,3}}, 4]
will generate
{e1_, e2_, e3_, e4_} -> {e1, e3, e2, e4}
For the permutations, I have
Permute[l, Cycles[cycles]]
but I cannot find a way of generating the list of patterns. Something subscripted or indexed would be nice as per the example. I have tried:
1) Pattern[Subscript[e, 1], Blank[]]
2) Pattern[Symbol["e1"], Blank[]]
3) Pattern[e[[1]], Blank[]]
I have a feeling I am missing something obvious.
Edit: Apologies for an oversight on my part. The second pattern example works correctly while the first and third do not. Thanks to all who responded.
Orderless
myself. $\endgroup$