code: def average(a, b, distance_function):
      
      distances = [distance_function(x, y)
                   for x in a for y in b]
      return sum(distances) / len(distances)
docs: Given two collections ``a`` and ``b``, this will return the mean of all
      distances. ``distance_function`` is used to determine the distance between
      two elements.
  
      Example::
  
          >>> single([1, 2], [3, 100], lambda x, y: abs(x-y))
          26