Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python sliding window

def window(iterable, size=2):
    i = iter(iterable)
    win = []
    for e in range(0, size):
        win.append(next(i))
    yield win
    for e in i:
        win = win[1:] + [e]
        yield win
Source by coderwall.com #
 
PREVIOUS NEXT
Tagged: #python #sliding #window
ADD COMMENT
Topic
Name
3+2 =