How to find the index of a maximal element in a list?
- To: mathgroup at smc.vnet.net
- Subject: [mg72911] How to find the index of a maximal element in a list?
- From: Valter Sorana <vsorana at yahoo.com>
- Date: Thu, 25 Jan 2007 06:19:20 -0500 (EST)
I may have a mental block, but I cannot find anything better than Position[listName,Max[listName]] that traverses the list twice - once to find the maximum and once to find where it is. Isn't there a way to get both the index and the max value in one go? (of course one could write a loop that does this, but I want to avoid loops) Thanks, Valter.
- Follow-Ups:
- Re: How to find the index of a maximal element in a list?
- From: Andrzej Kozlowski <akoz@mimuw.edu.pl>
- Re: How to find the index of a maximal element in a list?
- From: János <janos.lobb@yale.edu>
- Re: How to find the index of a maximal element in a list?
- From: Carl Woll <carlw@wolfram.com>
- Re: How to find the index of a maximal element in a list?