arg_max¶
Syntax¶
Parameters¶
list-expression- an expression that evaluates to a list
Returns¶
The index of the maximum value of the list parameter.
Description¶
Searches a list for its maximum element, and returns the index of the element.
Note that the index of the first element of a list is 0, the second element is 1, and so on.
The time complexity of this action is linear in relation to the size of the list.
It is an error if the argument is not a list-expression.
Examples¶
Find and print the max index of a list my_list and its value.
# Assuming my_list is defined earlier...
print("The max index of my_list is: ", arg_max(my_list))
print("Which contains the value: ", select(my_list, arg_max(my_list)))