I have the following list:
x=["A", "B", "B", "C", "B", "A", "D", "D", "A", "B", "A", "D"]
I wonder how does one partition into sublists of length 2 with offset 1 such that one gets:
#[["A", "B"], ["B", "B"], ["B", "C"], ["C", "B"], ["B", "A"], ["A",
# "D"], ["D", "D"], ["D", "A"], ["A", "B"], ["B", "A"], ["A", "D"]]
Also is there a generalised method for this? For example for different size of partition and different offsets? Suppose I want to partition into sublists of 3 with offset 2: for which I'd get
#[["A", "B", "B"], ["B", "C", "B"], ["B", "A", "D"], ["D", "D",
# "A"], ["A", "B", "A"]]
Is it possible to write this as a function, so for a given list, with given partition size and given number of offset it finds the sublists?