def pairs(seq):
    """Return a list of all adjacent elements."""
    if seq:
        iterable = iter(seq)
        prev = next(iterable)
        for _ in iterable:
            yield prev, _
            prev = _
