Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"If value corrupts then absolute value corrupts absolutely."


devel / comp.lang.python / Request for argmax(list) and argmin(list)

SubjectAuthor
* Request for argmax(list) and argmin(list)ABCCDE921
+- Re: Request for argmax(list) and argmin(list)Paul Rubin
+* Re: Request for argmax(list) and argmin(list)Paul Bryan
|`* Re: Request for argmax(list) and argmin(list)ABCCDE921
| +- Re: Request for argmax(list) and argmin(list)Calvin Spealman
| `- Re: Request for argmax(list) and argmin(list)Dan Stromberg
`- Re: Request for argmax(list) and argmin(list)Peter Otten

1
Request for argmax(list) and argmin(list)

<d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19277&group=comp.lang.python#19277

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:aed:2163:: with SMTP id 90mr6407192qtc.186.1630470317258;
Tue, 31 Aug 2021 21:25:17 -0700 (PDT)
X-Received: by 2002:a05:6214:1142:: with SMTP id b2mr32540454qvt.0.1630470317049;
Tue, 31 Aug 2021 21:25:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Tue, 31 Aug 2021 21:25:16 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=117.195.55.238; posting-account=8JdgzAoAAAD-OjbGgUYr-HP4gd5PFqbQ
NNTP-Posting-Host: 117.195.55.238
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>
Subject: Request for argmax(list) and argmin(list)
From: atharvasakhala5445@gmail.com (ABCCDE921)
Injection-Date: Wed, 01 Sep 2021 04:25:17 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 6
 by: ABCCDE921 - Wed, 1 Sep 2021 04:25 UTC

I dont want to import numpy

argmax(list)
returns index of (left most) max element

argmin(list)
returns index of (left most) min element

Re: Request for argmax(list) and argmin(list)

<87ilzkud7w.fsf@nightsong.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19278&group=comp.lang.python#19278

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.python
Subject: Re: Request for argmax(list) and argmin(list)
Date: Tue, 31 Aug 2021 21:33:23 -0700
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <87ilzkud7w.fsf@nightsong.com>
References: <d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="8623b3c32307081cab256e91f1086f19";
logging-data="5591"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19uIMO2OZdi/OotzKhka7b1"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:yc22PjxJz51GxW0UfI+I+2WJL1s=
sha1:ik7cbg1hztFgMDP+x1PK9MYHyuY=
 by: Paul Rubin - Wed, 1 Sep 2021 04:33 UTC

ABCCDE921 <atharvasakhala5445@gmail.com> writes:
> argmax(list)
> returns index of (left most) max element

Does this work?

def argmax(lst):
i,x = max(enumerate(xs), key=lambda a: a[1])
return i

Re: Request for argmax(list) and argmin(list)

<mailman.555.1630477931.4164.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19280&group=comp.lang.python#19280

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: pbryan@anode.ca (Paul Bryan)
Newsgroups: comp.lang.python
Subject: Re: Request for argmax(list) and argmin(list)
Date: Tue, 31 Aug 2021 23:32:06 -0700
Lines: 17
Message-ID: <mailman.555.1630477931.4164.python-list@python.org>
References: <d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>
<7031d0cbb8b2bfa31edb16995b5b6f2280c51cb8.camel@anode.ca>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de YvyGpg+yFjAX0fa5Hb/6MAABT7Icpx2GR8FxXBxMLvQg==
Return-Path: <pbryan@anode.ca>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=anode.ca header.i=@anode.ca header.b=lhbILHEP;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '&gt;&gt;&gt;': 0.07;
'-0700,': 0.09; 'numpy': 0.09; 'received:10.202': 0.09;
'received:10.202.2': 0.09; 'received:internal': 0.09;
'received:messagingengine.com': 0.09; 'subject:list': 0.11;
'import': 0.14; 'min': 0.16; 'received:10.202.2.162': 0.16;
'received:66.111': 0.16; 'received:66.111.4': 0.16; 'wrote:':
0.16; 'tue,': 0.18; 'returns': 0.23; 'to:addr:python-list': 0.23;
'>>>': 0.26; 'header:User-Agent:1': 0.31; 'skip:7 10': 0.32;
'header:In-Reply-To:1': 0.33; 'subject:for': 0.33; 'to:2**1':
0.38; '8bit%:14': 0.39; 'subject:Request': 0.40; 'subject:) ':
0.60; 'skip:\xc2 10': 0.62; '\xc2\xa0\xc2\xa0': 0.63; 'dont':
0.65; 'subject:(': 0.65
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anode.ca; h=
message-id:subject:from:to:date:in-reply-to:references
:content-type:mime-version; s=fm2; bh=Jcm3ghYxJttuDcnqCLRN59V3SH
RusqDAk+VKgKHh3zI=; b=lhbILHEPnyXnfFlcmVJ6+2Ib8htoHB04GBiOqgDxb0
as0diXFv59MVnOStXNB8J3cKfgpXeR+KY5yAC7wlK9rzRLRfaVb1Dv9e7YkRS8KR
SpgRhw+qayuHbjLiDfNkfHKXWims+EBhLxa+ZBxcMSP8n2ZE/U02R/RhKs7AcYJh
c1+J9vT4VIQs+ET+pGsvGO6YdDFeYVJm0w7S9sMR6hTyv08guJIbLMNXQkSi3UGf
lTHqZY/kp2/APAqb7wDA0YDiGk/rktlQDgsTz2xQdzzYj/vYSJ5kg0WfY1A0QBi/
gBhWadKkvx8VIZ2VQ5UFj6/f48cFU/Slm4j38AL6hVBQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=content-type:date:from:in-reply-to
:message-id:mime-version:references:subject:to:x-me-proxy
:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=Jcm3gh
YxJttuDcnqCLRN59V3SHRusqDAk+VKgKHh3zI=; b=eXegZZlFjVu1rmceTlrtFC
/UyZ8AFDzqBWpuOXtuUSKj0dyMjVP/nqLamNdoebX8OnYuAP1LxfYWl1ND5VP0xX
5w7oI9mhjlPkbVDOoNcCKdRjI+/ZGPRK1e7Sdzr4XCdHg7BIR62O7b+43aSjAgrc
16Szz4h3+C0HD49gmc6m7rDnTYEmyYA++9jU6UJh9VgyErZtUocUjruma9F9YN4d
5nfueYuprqgqEqzc9pNoHdHaAiBgVdBuUi9YsQeZBdimCRXTdcTEqRCcz5eWVAJs
ng2bMDiU1pf2oPihvXk7eppMt03rKw8jU/DSKHZyApRiSPy/a40abz7eUTW5T1xQ
==
X-ME-Sender: <xms:aB4vYS5tsz0eP-upfQUu9f8R9mY-18unYp3G_zSD27wO-PQ-kJhAQg>
<xme:aB4vYb7s2ksrunFoP44vpqUShtuBZCuQ39rCZJ36IrOHz13vi9ZmFJd7EBKZhP_ha
dPccDZaKh3wK1clJX8>
X-ME-Received: <xmr:aB4vYRfZcfdpEREezRh0SjPOr12K7s1b3g9krmIFVlRVNBkzGj--GnBwy5_jBeVPYrHV5CTv-vNztrhLZqML_2_LmO2qcebbKvDZzw>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddvvddguddtkecutefuodetggdotefrod
ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh
necuuegrihhlohhuthemuceftddtnecunecujfgurhepkffuhffvffgjfhgtfgggsegrtd
erredtreejnecuhfhrohhmpefrrghulhcuuehrhigrnhcuoehpsghrhigrnhesrghnohgu
vgdrtggrqeenucggtffrrghtthgvrhhnpedvtdetieekhfetlefgvdffieegteekkeevfe
egiefgteeijeeulefhfeehkeeigeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr
mhepmhgrihhlfhhrohhmpehpsghrhigrnhesrghnohguvgdrtggr
X-ME-Proxy: <xmx:aB4vYfKEm_yMWxnwTVYUIZgV2xj0u5puMylP9MbHaDoW2mGEWMGriA>
<xmx:aB4vYWLLBO8k_UmDFPasRwd6gqeD13I4GxYHHBMgJpA88_shrTp5YQ>
<xmx:aB4vYQxBAw_Os2xoVq5JSUKvqttScacJw9Mn5xlT_t3I7KFtWjpKnQ>
<xmx:aB4vYQxiIm38qmWrPRhc--0xwUzF57MC5PNxYiO2bWQSLjvME5r2SQ>
In-Reply-To: <d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>
User-Agent: Evolution 3.40.4
X-Content-Filtered-By: Mailman/MimeDel 2.1.34
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <7031d0cbb8b2bfa31edb16995b5b6f2280c51cb8.camel@anode.ca>
X-Mailman-Original-References: <d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>
 by: Paul Bryan - Wed, 1 Sep 2021 06:32 UTC

Why not:

>>> l = [1, 3, 5, 9, 2, 7]
>>> l.index(max(l))
3 >>> l.index(min(l))
0

On Tue, 2021-08-31 at 21:25 -0700, ABCCDE921 wrote:
> I dont want to import numpy
>
> argmax(list)
>    returns index of (left most) max element
>
>  argmin(list)
>    returns index of (left most) min element

Re: Request for argmax(list) and argmin(list)

<f86484d5-c781-4d56-989b-968f031cc358n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19281&group=comp.lang.python#19281

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:624a:: with SMTP id w71mr6971646qkb.81.1630480818716;
Wed, 01 Sep 2021 00:20:18 -0700 (PDT)
X-Received: by 2002:a37:66d1:: with SMTP id a200mr6869704qkc.440.1630480818559;
Wed, 01 Sep 2021 00:20:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Wed, 1 Sep 2021 00:20:18 -0700 (PDT)
In-Reply-To: <mailman.555.1630477931.4164.python-list@python.org>
Injection-Info: google-groups.googlegroups.com; posting-host=117.195.63.157; posting-account=8JdgzAoAAAD-OjbGgUYr-HP4gd5PFqbQ
NNTP-Posting-Host: 117.195.63.157
References: <7031d0cbb8b2bfa31edb16995b5b6f2280c51cb8.camel@anode.ca>
<d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com> <mailman.555.1630477931.4164.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f86484d5-c781-4d56-989b-968f031cc358n@googlegroups.com>
Subject: Re: Request for argmax(list) and argmin(list)
From: atharvasakhala5445@gmail.com (ABCCDE921)
Injection-Date: Wed, 01 Sep 2021 07:20:18 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 18
 by: ABCCDE921 - Wed, 1 Sep 2021 07:20 UTC

Because that does 2 passes over the entire array when you only need one and there is no option to specify if you want the leftmost or rightmost element

On Wednesday, September 1, 2021 at 12:02:29 PM UTC+5:30, Paul Bryan wrote:
> Why not:
>
> >>> l = [1, 3, 5, 9, 2, 7]
> >>> l.index(max(l))
> 3
> >>> l.index(min(l))
> 0
> On Tue, 2021-08-31 at 21:25 -0700, ABCCDE921 wrote:
> > I dont want to import numpy
> >
> > argmax(list)
> > returns index of (left most) max element
> >
> > argmin(list)
> > returns index of (left most) min element

Re: Request for argmax(list) and argmin(list)

<mailman.556.1630481791.4164.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19283&group=comp.lang.python#19283

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: __peter__@web.de (Peter Otten)
Newsgroups: comp.lang.python
Subject: Re: Request for argmax(list) and argmin(list)
Date: Wed, 1 Sep 2021 09:21:30 +0200
Lines: 22
Message-ID: <mailman.556.1630481791.4164.python-list@python.org>
References: <d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>
<sgnaho$ara$1@ciao.gmane.io>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de BItS7QSwm4OhaUq1kG3rNwA2Z4Sofy3VlltFvL7ggpCw==
Return-Path: <python-python-list@m.gmane-mx.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.007
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'def': 0.04; 'message-
id:@ciao.gmane.io': 0.09; 'numpy': 0.09; 'received:ciao.gmane.io':
0.09; 'received:gmane.io': 0.09; 'received:list': 0.09;
'subject:list': 0.11; 'import': 0.14; 'from:addr:web.de': 0.16;
'min': 0.16; 'received:116.202': 0.16; 'received:116.202.254':
0.16; 'received:116.202.254.214': 0.16; 'wrote:': 0.16; 'returns':
0.23; 'to:addr:python-list': 0.23; '>>>': 0.26; 'header:User-
Agent:1': 0.31; 'header:In-Reply-To:1': 0.33; 'subject:for': 0.33;
'subject:Request': 0.40; 'subject:) ': 0.60; 'skip:m 20': 0.64;
'skip:k 10': 0.64; 'dont': 0.65; 'subject:(': 0.65; 'skip:o 20':
0.67; 'received:116': 0.71; 'left': 0.79
X-Injected-Via-Gmane: http://gmane.org/
User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>
Content-Language: en-US
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <sgnaho$ara$1@ciao.gmane.io>
X-Mailman-Original-References: <d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>
 by: Peter Otten - Wed, 1 Sep 2021 07:21 UTC

On 01/09/2021 06:25, ABCCDE921 wrote:
> I dont want to import numpy
>
> argmax(list)
> returns index of (left most) max element

>>> import operator
>>> second = operator.itemgetter(1)
>>> def argmax(values):
return max(enumerate(values), key=second)[0]

>>> argmax([1, 2, 3, 0])
2

> argmin(list)
> returns index of (left most) min element

This is left as an exercise;)

Re: Request for argmax(list) and argmin(list)

<mailman.560.1630507611.4164.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19289&group=comp.lang.python#19289

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: cspealma@redhat.com (Calvin Spealman)
Newsgroups: comp.lang.python
Subject: Re: Request for argmax(list) and argmin(list)
Date: Wed, 1 Sep 2021 10:46:07 -0400
Lines: 42
Message-ID: <mailman.560.1630507611.4164.python-list@python.org>
References: <7031d0cbb8b2bfa31edb16995b5b6f2280c51cb8.camel@anode.ca>
<d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>
<mailman.555.1630477931.4164.python-list@python.org>
<f86484d5-c781-4d56-989b-968f031cc358n@googlegroups.com>
<CACo5Rz5H34U=wAjsFer0G0ZnhtpQMy_4oYMCjXLmoGNNZhvkPg@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de GUm67yWBKKxYWUC3dZa2eQlWHCKUfSotmPg4AOeaiAGA==
Return-Path: <cspealma@redhat.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="1024-bit key; unprotected key"
header.d=redhat.com header.i=@redhat.com header.b=ZTmKlQND;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.008
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'engineer': 0.02;
'&gt;&gt;&gt;': 0.07; 'url:mailman': 0.09; '-0700,': 0.09;
'cc:addr:python-list': 0.09; 'numpy': 0.09; 'url-
ip:67.199.248.12/32': 0.09; 'url-ip:67.199.248.13/32': 0.09;
'subject:list': 0.11; 'import': 0.14; '&gt;': 0.14;
'cc:name:python': 0.16; 'min': 0.16; 'specify': 0.16;
'url:latest': 0.16; 'wrote:': 0.16; 'url:listinfo': 0.16; 'tue,':
0.18; 'wednesday,': 0.18; 'cc:addr:python.org': 0.19; 'url-
ip:188.166.95.178/32': 0.20; 'url-ip:188.166.95/24': 0.20;
'option': 0.21; 'url-ip:188.166/16': 0.23; 'returns': 0.23; '>>>':
0.26; 'cc:2**0': 0.27; 'library': 0.27; 'url-ip:188/8': 0.29;
'there': 0.31; 'passes': 0.32; 'sep': 0.32; 'message-
id:@mail.gmail.com': 0.33; 'header:In-Reply-To:1': 0.33;
'subject:for': 0.33; 'functions': 0.34; 'received:google.com':
0.34; 'received:209.85.167': 0.37; 'received:209.85': 0.38;
'received:209': 0.38; 'does': 0.38; '[image:': 0.40;
'subject:Request': 0.40; 'subject:) ': 0.60; 'entire': 0.61; 'url-
ip:67/8': 0.62; 'url:png': 0.64; 'dont': 0.65; 'subject:(': 0.65;
'exactly': 0.69; 'url:logo': 0.69; 'paul': 0.81; 'received:170':
0.81; 'quality': 0.83; '2021': 0.84; 'bryan': 0.84; 'url:sig':
0.91; 'url-ip:209/8': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
s=mimecast20190719; t=1630507582;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:cc:mime-version:mime-version:content-type:content-type:
in-reply-to:in-reply-to:references:references;
bh=UBIsWfbUPLNHXvzD/LPg292xZIfdNxE4Y7Zcht0je5A=;
b=ZTmKlQND7jk2LDGi/DcpN/JwOiXwxowNvy92fQx2IuSF0Qw7YFTaW9IkMfwV1YCApZt68N
RsjBZ1ms5swhWWVJFmrKf3LXCF5kMZi03mIn2cPLLDNnMJUyrXBTk7zg2lkJj4w2OT9lLe
u7sMGRuh4ZDftDT5vHVxvWiEmHdst8U=
X-MC-Unique: A_qjVsSFMU2mzEqthLPL7Q-1
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=UBIsWfbUPLNHXvzD/LPg292xZIfdNxE4Y7Zcht0je5A=;
b=ANj95H3zrRg+N3Gj/4+YRZRKVju5kctMqLZ1j8DAlXXpW8Ro4T15caKav0a6rk/8LU
QDhpnovlEnChNB98Ssk7Hf3OQ4mc5cHnq7z3f87ryPrm3iEPimurrtUgf6Wab72WMWIg
MsnznAlu5/t/EAS+DWfhj8UivC0kw/LtOvDxa7azmaynOddgGX/lNq6IzNt+J7SgUASR
8/eMHftthhIPNl51qM1GKYNow9Tlhb+1jsGUopAI/BvIiXk5B4+F7uWgKuKit5vNjTPA
RTMyQ1B9iY25p+enCzsIhth/Lw/7PY/VyhGII7Vrocj795xl5F1nZxBXOsm9e39qjRkE
hFXg==
X-Gm-Message-State: AOAM532SnjFqu99SJd2/NQIlTwtQQo5VVBJhUbcZ1I6140pJoSQLPNvV
n+G8sJ/4r8gZnbBc2yVELj6UL2y627lUqef5sqHDAMrxMZUGSAJfRkAtHKIm1dAV0q7xXD9zuMo
yC7lY/EXR+lGQ3s58mLKrwt4VxOojib2W
X-Received: by 2002:aca:1e11:: with SMTP id m17mr7478550oic.104.1630507578115;
Wed, 01 Sep 2021 07:46:18 -0700 (PDT)
X-Google-Smtp-Source: ABdhPJxcqYNlqh3knfDZ1Bc/LH+AgnymvRstyeWdVY2bcjwKMz6ahDc/np3no8JWnS9iZj/w+rKC82Cd5PNAbd+cFxc=
X-Received: by 2002:aca:1e11:: with SMTP id m17mr7478544oic.104.1630507577935;
Wed, 01 Sep 2021 07:46:17 -0700 (PDT)
In-Reply-To: <f86484d5-c781-4d56-989b-968f031cc358n@googlegroups.com>
Authentication-Results: relay.mimecast.com;
auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cspealma@redhat.com
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
X-Content-Filtered-By: Mailman/MimeDel 2.1.34
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CACo5Rz5H34U=wAjsFer0G0ZnhtpQMy_4oYMCjXLmoGNNZhvkPg@mail.gmail.com>
X-Mailman-Original-References: <7031d0cbb8b2bfa31edb16995b5b6f2280c51cb8.camel@anode.ca>
<d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>
<mailman.555.1630477931.4164.python-list@python.org>
<f86484d5-c781-4d56-989b-968f031cc358n@googlegroups.com>
 by: Calvin Spealman - Wed, 1 Sep 2021 14:46 UTC

If only there were a library that already provides exactly the functions
you're asking for... 🤔

On Wed, Sep 1, 2021 at 9:54 AM ABCCDE921 <atharvasakhala5445@gmail.com>
wrote:

> Because that does 2 passes over the entire array when you only need one
> and there is no option to specify if you want the leftmost or rightmost
> element
>
>
> On Wednesday, September 1, 2021 at 12:02:29 PM UTC+5:30, Paul Bryan wrote:
> > Why not:
> >
> > >>> l = [1, 3, 5, 9, 2, 7]
> > >>> l.index(max(l))
> > 3
> > >>> l.index(min(l))
> > 0
> > On Tue, 2021-08-31 at 21:25 -0700, ABCCDE921 wrote:
> > > I dont want to import numpy
> > >
> > > argmax(list)
> > > returns index of (left most) max element
> > >
> > > argmin(list)
> > > returns index of (left most) min element
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

--

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.spealman@redhat.com M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>

Re: Request for argmax(list) and argmin(list)

<mailman.586.1630620887.4164.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19340&group=comp.lang.python#19340

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: drsalists@gmail.com (Dan Stromberg)
Newsgroups: comp.lang.python
Subject: Re: Request for argmax(list) and argmin(list)
Date: Thu, 2 Sep 2021 15:14:33 -0700
Lines: 33
Message-ID: <mailman.586.1630620887.4164.python-list@python.org>
References: <7031d0cbb8b2bfa31edb16995b5b6f2280c51cb8.camel@anode.ca>
<d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>
<mailman.555.1630477931.4164.python-list@python.org>
<f86484d5-c781-4d56-989b-968f031cc358n@googlegroups.com>
<CAGGBd_rOF=MuMuqn=VL5TEXFNR3ptn5RyNnV03aVZDuKSkTm4A@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de bcdekr/KbdmXT6yekd5LEgOi0ytixBsOQZgPX12Pcn8w==
Return-Path: <drsalists@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=AhEr+o2w;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '&gt;&gt;&gt;': 0.07;
'url:mailman': 0.09; '-0700,': 0.09; 'cc:addr:python-list': 0.09;
'numpy': 0.09; 'subject:list': 0.11; 'import': 0.14; '&gt;': 0.14;
'6:51': 0.16; 'cc:name:python list': 0.16; 'from:addr:drsalists':
0.16; 'from:name:dan stromberg': 0.16; 'min': 0.16; 'python3':
0.16; 'specify': 0.16; 'wrote:': 0.16; 'url:listinfo': 0.16;
'tue,': 0.18; 'wednesday,': 0.18; 'cc:addr:python.org': 0.19;
'url-ip:188.166.95.178/32': 0.20; 'url-ip:188.166.95/24': 0.20;
'option': 0.21; 'url-ip:188.166/16': 0.23; 'returns': 0.23; '>>>':
0.26; 'cc:2**0': 0.27; 'url-ip:188/8': 0.29; 'there': 0.31;
'passes': 0.32; 'sep': 0.32; 'message-id:@mail.gmail.com': 0.33;
'header:In-Reply-To:1': 0.33; 'subject:for': 0.33;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35;
'received:209.85': 0.38; 'received:209': 0.38; 'does': 0.38;
'subject:Request': 0.40; 'subject:) ': 0.60; 'skip:e 10': 0.60;
'entire': 0.61; 'dont': 0.65; 'subject:(': 0.65; 'paul': 0.81;
'2021': 0.84; 'bryan': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=GNG3eDFiZXUDhh5h0auAVQoagO5aRYSpNDqM+T/UtKk=;
b=AhEr+o2wHDFgCKAkdmNUmjLAGUk8sLC+KUcwVB5jFvEMdGNLDbVpoVOGFvwwVnFFG9
jGzElRSbYoZea1kxcVtAJ1zM0nFGlMhsUiMqd+2ut9sr/OoUkHmvoS/SwcmZ4PWnUIIE
tDW0qkbaI8tEXr2+eimkHyS91oIt0ocw/kWLE2FtXLyGs0ovQI231YTj4YNoEnTK8QvC
Jif7t0VDNoAZWD/1Kkv9F6SNmxyJBINpeIMtxM9e2Yt23q3Mg/b31JUHZaa1XGjWSQBv
0A0kQepkUu47nkuj2L4yB7xz11qh4Sr5e6zdo64o+CU2MUn6MDzphF9xST54n1GRtSH4
g6eg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=GNG3eDFiZXUDhh5h0auAVQoagO5aRYSpNDqM+T/UtKk=;
b=Bh5HKj3A5q+irMV4rKuEg5iFz8WRKlK//xachRmJh0iemldYLbIYmJwqbl6+P0pu8L
KkciiVRbn/SPKRogtuj0LmD9f2ZmiP5IWN2D4Kafx7JfAc8lJ4ys6sIwW9dwXmDKb9K/
gxFIlGX/RlAdL2e0Y3qTwTpnAP/Ws9cbZsHGITa+vuPW/s4XZDGb3uuPbEv+DmJRNKAf
3ZnTiaaJjTgBuDe13IfLHA6iBqyxliia4r2JhT47k01yuwTHu/w6SXVzum+tK+TdYcte
0Y3liyZBpXC8rZA2QHTVLCpMzbaLXcSbx+W3t4iDpxAHnX5IAYdWhbAxbTRJ03i6IJ2Q
dMIw==
X-Gm-Message-State: AOAM531gypEa7MwCTgXr996TY6XERk2gbluXHsCO2u0+4gGEY00ek6HV
BjraI6kaVEsQRgE+64xS+6gMZ7XutOicrMjfexOxL0fj0b8=
X-Google-Smtp-Source: ABdhPJwXq0Ynu0OCB1DtxQJKbzJA8mLTX+id5doQ0U4mNHK68N8dIsbxbFoXYH+NI8YcAgShNXWY5gPY9eH4rc1vKO8=
X-Received: by 2002:ab0:5555:: with SMTP id u21mr326865uaa.79.1630620884622;
Thu, 02 Sep 2021 15:14:44 -0700 (PDT)
In-Reply-To: <f86484d5-c781-4d56-989b-968f031cc358n@googlegroups.com>
X-Content-Filtered-By: Mailman/MimeDel 2.1.34
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAGGBd_rOF=MuMuqn=VL5TEXFNR3ptn5RyNnV03aVZDuKSkTm4A@mail.gmail.com>
X-Mailman-Original-References: <7031d0cbb8b2bfa31edb16995b5b6f2280c51cb8.camel@anode.ca>
<d01a8701-d4e8-42bc-a42c-f642344f1124n@googlegroups.com>
<mailman.555.1630477931.4164.python-list@python.org>
<f86484d5-c781-4d56-989b-968f031cc358n@googlegroups.com>
 by: Dan Stromberg - Thu, 2 Sep 2021 22:14 UTC

How about this?:

python3 -c 'list_ = [1, 3, 5, 4, 2]; am = max((value, index) for index,
value in enumerate(list_)); print(am)'

On Wed, Sep 1, 2021 at 6:51 AM ABCCDE921 <atharvasakhala5445@gmail.com>
wrote:

> Because that does 2 passes over the entire array when you only need one
> and there is no option to specify if you want the leftmost or rightmost
> element
>
>
> On Wednesday, September 1, 2021 at 12:02:29 PM UTC+5:30, Paul Bryan wrote:
> > Why not:
> >
> > >>> l = [1, 3, 5, 9, 2, 7]
> > >>> l.index(max(l))
> > 3
> > >>> l.index(min(l))
> > 0
> > On Tue, 2021-08-31 at 21:25 -0700, ABCCDE921 wrote:
> > > I dont want to import numpy
> > >
> > > argmax(list)
> > > returns index of (left most) max element
> > >
> > > argmin(list)
> > > returns index of (left most) min element
> --
> https://mail.python.org/mailman/listinfo/python-list
>


devel / comp.lang.python / Request for argmax(list) and argmin(list)

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor