Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'argument': 0.05; 'subject:Python': 0.06; 'variables': 0.07; 'funny,': 0.09; 'parameter': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:language': 0.09; 'translate': 0.10; 'python': 0.11; 'jan': 0.12; '(lambda': 0.16; 'camp': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject: \n ': 0.16; 'wrote:': 0.18; 'trying': 0.19; '>>>': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'math': 0.24; 'equivalent': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; "doesn't": 0.30; 'subject:list': 0.30; 'code': 0.31; 'but': 0.35; 'really': 0.36; 'programming,': 0.36; 'scheme': 0.36; 'implement': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'functional': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'received:173': 0.61; 'skip:* 10': 0.61; 'subject:this': 0.83; 'dialect': 0.84; 'received:fios.verizon.net': 0.84; 'understand,': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list) Date: Mon, 24 Mar 2014 21:31:46 -0400 References: <9daf0806-02de-4447-964c-c8f8953c23e5@googlegroups.com> <10101874-2995-4acd-9851-989603f052e3@googlegroups.com> <532d5bd9$0$29994$c3e8da3$5496439d@news.astraweb.com> <87ior3w740.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-254-207.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395711130 news.xs4all.nl 2854 [2001:888:2000:d::a6]:56306 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68927 On 3/24/2014 8:28 PM, Chris Angelico wrote: > Pure functional programming, from what I understand, doesn't *have* > variables other than function arguments. function *parameters*, if in the 'variable = name' camp > So the way to implement "x = 1" is to call a subfunction with a parameter named 'x' > with an argument of 1 Funny, I was just thinking about that last night. I really learned it when trying to translate python code to the scheme dialect racket. import math as m s = m.sqrt(2) a = m.sin(s) + m.cos(s) del s # to be exactly equivalent to the below, but not needed b = (lambda x: m.sin(x) + m.cos(x))(m.sqrt(2)) print(a,b) >>> 1.14370964075811 1.14370964075811 -- Terry Jan Reedy