code: def map_indices(fn, iterable, indices):
      r
      index_set = set(indices)
      for i, arg in enumerate(iterable):
          if i in index_set:
              yield fn(arg)
          else:
              yield arg
docs: r"""
      Map a function across indices of an iterable.
  
      Notes
      -----
      Roughly equivalent to, though more efficient than::
  
          lambda fn, iterable, *indices: (fn(arg) if i in indices else arg
                                          for i, arg in enumerate(iterable))
  
      Examples
      --------
  
      >>> a = [4, 6, 7, 1, 6, 8, 2]
  
      >>> from operator import mul
      >>> list(map_indices(partial(mul, 3), a, [0, 3, 5]))
      [12, 6, 7, 3, 6, 24, 2]
  
      >>> b = [9., np.array([5., 6., 2.]),
      ...      np.array([[5., 6., 2.], [2., 3., 9.]])]
  
      >>> list(map_indices(np.log, b, [0, 2])) # doctest: +NORMALIZE_WHITESPACE
      [2.1972245773362196,
       array([ 5.,  6.,  2.]),
       array([[ 1.60943791,  1.79175947,  0.69314718],
              [ 0.69314718,  1.09861229,  2.19722458]])]
  
      .. todo::
  
         Floating point precision
  
      >>> list(map_indices(np.exp, list(map_indices(np.log, b, [0, 2])), [0, 2]))
      ... # doctest: +NORMALIZE_WHITESPACE +SKIP
      [9.,
       array([5., 6., 2.]),
       array([[ 5.,  6.,  2.],
              [ 2.,  3.,  9.]])]