Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93166
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.013 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'subject:process': 0.09; 'subject:skip:m 10': 0.09; 'def': 0.14; 'argument': 0.15; 'thu,': 0.15; 'lambda': 0.16; 'subject:Could': 0.16; 'subject:detail': 0.16; 'wrote:': 0.16; 'first.': 0.18; 'passes': 0.18; 'creates': 0.18; 'code.': 0.23; '2015': 0.23; 'header:In-Reply-To:1': 0.24; 'example': 0.25; 'parameters': 0.27; 'message-id:@mail.gmail.com': 0.28; 'tutorial': 0.29; 'function': 0.30; 'print': 0.31; 'gets': 0.32; 'returned': 0.32; 'received:google.com': 0.34; 'gives': 0.35; 'to:addr:python-list': 0.35; 'clear': 0.35; 'two': 0.37; 'hi,': 0.37; 'subject:: ': 0.37; 'or,': 0.38; 'pm,': 0.39; 'to:addr:python.org': 0.39; 'takes': 0.39; 'subject:the': 0.40; 'to:name:python': 0.84; 'subject:you': 0.88 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Nk1RdgzoTIh6F2J0SvZTCCX8vvZUu/ZIyGigUaZE6U8=; b=ENS5a0DYOyRvrCzLP9V/dh+iZHG1UzoZDdvOT12fZ6u5plmexbLZ6yH17vhlK8nUSo UKN5xbZ1UIZ6oVElzPvzRs+izg2+XJNtwD4RgNO299oMI7FfLF/Fz1tJzN/uMAo83WEq UwH9kFHB8PE71hp/cCxB1nH+dcwtiTsDJb/OMGKBkQ7CLHTlnUeu2DrxQUyt/e/WGJ3o OyFCDPrsFZM3U2QFskwMuGRHr7BmO71NykiruRhPmmsC8YxnamZT9qQmXzFksVU43/ZW X0sI7EM0lovsP2uy1TcAx+qyz5z268z7PjTZnS8kEmRf9hz0tsiQy2UxgwQogfSf29XM K8cA== |
| X-Received | by 10.129.36.14 with SMTP id k14mr56202086ywk.64.1435267404543; Thu, 25 Jun 2015 14:23:24 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <20661fcb-7773-4f17-bbfa-8533914e637f@googlegroups.com> |
| References | <20661fcb-7773-4f17-bbfa-8533914e637f@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Thu, 25 Jun 2015 15:22:45 -0600 |
| Subject | Re: Could you give me the detail process of 'make_incrementor(22)(33)'? |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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 | <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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.84.1435267411.3674.python-list@python.org> (permalink) |
| Lines | 25 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1435267411 news.xs4all.nl 2830 [2001:888:2000:d::a6]:34442 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:93166 |
Show key headers only | View raw
On Thu, Jun 25, 2015 at 2:53 PM, fl <rxjwg98@gmail.com> wrote: > Hi, > > I read a tutorial on lambda on line. I don't think that I am clear about > the last line in its example code. It gives two parameters (22, 23). > Is 22 for n, and 23 for x? Or, it creates two functions first. Then, > each function gets 22 while the other function gets 23? > > >>>> def make_incrementor (n): return lambda x: x + n >>>> >>>> f = make_incrementor(2) >>>> g = make_incrementor(6) >>>> >>>> print f(42), g(42) > 44 48 >>>> >>>> print make_incrementor(22)(33) make_incrementor is a function that takes an argument n. It returns a function that takes an argument x. So when you do make_incrementor(22) that passes 22 to make_incrementor as the value of n, and when you do make_incrementor(22)(33), that also passes 22 to make_incrementor as the value of n, and then it passes 33 to the returned function as the value of x.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Could you give me the detail process of 'make_incrementor(22)(33)'? fl <rxjwg98@gmail.com> - 2015-06-25 13:53 -0700 Re: Could you give me the detail process of 'make_incrementor(22)(33)'? Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-25 15:22 -0600
csiph-web