假设我有以下列表的列表:
x = [[1,2,3],[4,5,6],[7,8,9,10]]
我希望选择所有大小为 n=4
的“窗口”,并以间隔距离为 d=2
的方式进行操作:
[[1,2,3],[4]] # Starts at position `0`
[[3],[4,5,6]] # Starts at position `d`
[[5,6],[7,8]] # Starts at position `2d`
[[7,8,9,10]] # Starts at position `3d`
我希望您能够理解,我需要在窗口与子列表相重叠的地方取交集。这与IT技术有关,以下是需要翻译的内容:
那么,我该如何做呢?