libb.map

map(func, *iterables)[source]

Simulate a Python 2-like map with longest iterable behavior.

Continues until the longest of the argument iterables is exhausted, extending the other arguments with None.

Parameters:
  • func – Function to apply (or None for tuple aggregation).

  • iterables – Iterables to map over.

Returns:

Iterator of mapped results.

Example:

>>> def foo(a, b):
...     if b is not None:
...         return a - b
...     return -a
>>> list(map(foo, range(5), [3,2,1]))
[-3, -1, 1, -3, -4]