utils.collection_helper

collection_helper

Please Reference ding/ding/utils/collection_helper.py for usage.

iter_mapping

Overview:

Map a list of iterable elements to input iteration callable

Arguments:
  • iter_(_IterType list): The list for iteration

  • mapping (Callable [[_IterType], _IterTargetType]): A callable that maps iterable elements function.

Return:
  • (iter_mapping object): Iteration results

Example:
>>> iterable_list = [1, 2, 3, 4, 5]
>>> _iter = iter_mapping(iterable_list, lambda x: x ** 2)
>>> print(list(_iter))
[1, 4, 9, 16, 25]