Search code examples
pythonpython-3.xminiterable

min() function in python3


It seems that the inbuilt min() function for determining the minimum value in a given iterable. I have this line of code:

result = min(cost+futureCost(newState) \
                for action, newState, cost in problem.succAndCost(state))

where newState is of integer type and the function futureCost() returns an integer. How the enclosed parameters form an iterable in this case?


Solution

  • This is called a generator expression. https://www.python.org/dev/peps/pep-0289