def sliding_window(l, n):
  """
  Creates a sliding window of given length over a list.
  
  Examples
  --------
  >>> l = range(5)
  >>> sliding_window(l, 2)
  [[0, 1], [1, 2], [2, 3], [3, 4]]
  """
  rngs = range(0, len(l) - n + 1)
  return map(lambda rng: l[rng:rng + n], rngs)