How to fix the position of maximal or minimal element(s) in one List.
- To: mathgroup at smc.vnet.net
- Subject: [mg92117] How to fix the position of maximal or minimal element(s) in one List.
- From: Aya <sh_liuhuashan at 163.com>
- Date: Sat, 20 Sep 2008 05:00:52 -0400 (EDT)
Hi friends:
To fix the position of maximal or minimal element(s) in one List,
I code as follows:
------------------------------
MaxElementPosition[ list_?ListQ ] := Position[ list, Max[list]]
[[1,1]];
MinElementPosition[ list_?ListQ ] := Position[ list, Min[list]]
[[1,1]];
e.g.
lst = {3, 2, 4,2,1}
MaxElementPosition[lst] ----------> 3
MinElementPosition[lst] -----------> 5
------------------------------
would you show me more efficient mathelets to update them.
Thanks~~~