import itertools


def pairwise(iterable):
    """
    Iterate pairwise over an iterable.

    The function follows the recipe offered on Python's `itertools`
    documentation.

    Parameters
    ----------
    iterable : iter
        The iterable to be iterate pairwise.

    Examples
    --------

    >>> import dafsa
    >>> list(dafsa.utils.pairwise([1,2,3,4,5]))
    [(1, 2), (2, 3), (3, 4), (4, 5)]
    """

    elem_a, elem_b = itertools.tee(iterable)
    next(elem_b, None)

    return zip(elem_a, elem_b)