prelude.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:concepts 作者: sminez 项目源码 文件源码
def iwindowed(iterable, n):
    '''
    Take successive n-tuples from an iterable using a sliding window
    '''
    # Take n copies of the iterable
    iterables = tee(iterable, n)

    # Advance each to the correct starting position
    for step, it in enumerate(iterables):
        for s in range(step):
            next(it)

    # Zip the modified iterables and yield the elements as a genreator
    # NOTE: not using zip longest as we want to stop when we reach the end
    for t in zip(*iterables):
        yield t
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号