How can I name a repeated pattern to apply a rule on it? In the example below I have two element sequence. There is no problem in naming them and then applying some function on it:
ClearAll[f];
SequenceReplace[{1, 1, 2, 3, 4, 5}, {a_, b_} /; b > 1.2 a :>
f[{a, b}]]
What if the length of the sequence is variable, say of size k
with some constraint on that pattern {_,_ ,etc}
? There is Repeated[_, {k}]
. But how to pass it to the function f
?