Names such as map
, filter
or sum
are generally understood by every resonably good programmer.
I wonder whether the following function f
also has such a standard name:
def f(data, idx): return [data[i] for i in idx]
Example usages:
r = f(['world', '!', 'hello'], [2, 0, 1, 1, 1])
piecePrice = [100, 50, 20, 180]
pieceIdx = [0, 2, 3, 0, 0]
total Price = sum(f(piecePrice, pieceIdx))
I started with map
, but map
is generally understood as a function that applies a function on each element of a list.