Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35166
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ckaynor@zindagigames.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.014 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; '(python': 0.05; 'callable': 0.09; 'thx': 0.09; 'cc:addr:python-list': 0.10; 'dec': 0.15; 'lambda': 0.16; 'wed,': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'email addr:gmail.com>': 0.20; '>>>': 0.22; 'simpler': 0.22; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In- Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'arguments.': 0.29; 'skip:& 10': 0.29; 'probably': 0.29; 'function': 0.30; 'subject:lists': 0.32; 'cases,': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'replaced': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'tool': 0.36; 'skip:z 10': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'takes': 0.39; 'header:Received:5': 0.40; 'map': 0.61; '\xa0have': 0.84; '======': 0.91 |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:x-gm-message-state; bh=mmDXvs3YBOgyuSL9DBCXAMsxEkGYP7MREACqFp/gp0w=; b=HdVJnyVX/Nz/hRqRahjBepXFVK4iSJ/xJxZNsfB3BMncdsLlHbniwfqveB5MoFRGPc eeD2LEAHWAJ2QHVnQMJoTAIcv6dvgQvxVHLX8iUByQGhc/IHBjefwFB1kVMBjwj+HTKT JDTEM3VemlRRv1mdKQcAryyHoxCHh6NDe43GDQqGSZdbecyg9iRlvBn3wdN94jft367h 9x4CBRKEi+FNEoROlmaU4YgQyYFRYRbZBAbp8fy+TaJ+yWq+J3ix3CraFrPwusS6fxqX MKLIAkhQfhmRc0yUiOHvMDB+Ym1YMzEK0jhKCbx2m7CEWPXhQX3jbxDY7Rc2nYNZJgtT 0Usw== |
| MIME-Version | 1.0 |
| In-Reply-To | <CAHzaPEPXMLSqhqyzSj96xFcedjr=HeoPv+d_xGrOwXAqLe-PFQ@mail.gmail.com> |
| References | <BLU168-W121B52F2829276D9EC909658F300@phx.gbl> <CAHzaPEPXMLSqhqyzSj96xFcedjr=HeoPv+d_xGrOwXAqLe-PFQ@mail.gmail.com> |
| From | Chris Kaynor <ckaynor@zindagigames.com> |
| Date | Wed, 19 Dec 2012 09:11:14 -0800 |
| Subject | Re: calculation on lists |
| To | Vlastimil Brom <vlastimil.brom@gmail.com> |
| Content-Type | multipart/alternative; boundary=20cf30334ecb84818404d13db113 |
| X-Gm-Message-State | ALoCoQkrDS9r9VFsyU0VT0Y1HC7kdRq7voS0iMl42xcd9Aj/o3gTEBP/XIksWZuS9NLMU87BUMiA |
| Cc | "python-list@python.org" <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1078.1355962816.29569.python-list@python.org> (permalink) |
| Lines | 86 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1355962816 news.xs4all.nl 6909 [2001:888:2000:d::a6]:50994 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:35166 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Wed, Dec 19, 2012 at 4:38 AM, Vlastimil Brom <vlastimil.brom@gmail.com>wrote: > 2012/12/19 loïc Lauréote <laureote-loic@hotmail.fr>: > hi, > I > have a question, > is there a tool to calculate on list ? > > something like : > > >a= [1,1,1,1] > >b = [5,9,8,4] > >c = a+b*a > >print c > >[6,10,9,5] > > Thx > > ====== > > Hi, > for such simpler cases, you may try list comprehensions and probably > the zip(...) function > > >>> [a+b*a for a,b in zip([1,1,1,1], [5,9,8,4])] > [6, 10, 9, 5] > >>> > You can also use map (Python 2.6): map(lambda a,b: a+b*a, [1,1,1,1], [5,9,8,4]) Note that the lambda can be replaced by any callable which takes 2 arguments.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: calculation on lists Chris Kaynor <ckaynor@zindagigames.com> - 2012-12-19 09:11 -0800
csiph-web