Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.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.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:Python': 0.05; 'python': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; '3.3,': 0.16; '[x]': 0.16; 'heap': 0.16; 'syntax.': 0.16; 'wrote:': 0.17; 'yield': 0.17; 'cheers,': 0.23; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'looks': 0.26; 'tail': 0.29; 'fri,': 0.30; 'could': 0.32; 'anyone': 0.33; 'nov': 0.35; 'replaced': 0.35; 'pm,': 0.35; 'there': 0.35; 'next': 0.35; 'anything': 0.36; 'should': 0.36; 'subject:: ': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'more': 0.63; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; '(head': 0.84 Date: Fri, 02 Nov 2012 18:24:57 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 MIME-Version: 1.0 To: Ian Kelly Subject: Re: Haskell -> Python References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:xPVMg0SbrHwhKryliowKPf3hsmNkn9LNSYr2w7/qxvg Ft8fQFzq9TKE/2wZztisyMKAjv9WpU00LQlJrqc2VqnuGiLgMb 08VRht+hQVWNKKxDV0pcVU2c6b0HQTz8CKxL1BnduCz7Ggbr5c qHnSnYmq73kOJuXNCujA0StZeQVBlb39zwG6obsztoPhv/fWhe zs6eKIMIuZO+mPeTxF2suz9YZFQ6UJN8q0vt59VM4Sft6wgmov sYZVyi0ShQiSYGy+VNwYJq3IOY0D4jcnrUCUG4LJG6d1ych5ws E4xBOh48R1+D6TYCLvAWlfgwC3BmNjS3m7e0YyHNjfJ4h62vw= = Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351895130 news.xs4all.nl 6943 [2001:888:2000:d::a6]:42832 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32669 On 11/02/2012 05:40 PM, Ian Kelly wrote: > On Fri, Nov 2, 2012 at 1:19 PM, wrote: >> Is there anything anyone could recommend to make it more "Pythonic" or more functional. It looks clumsy next to the Haskell. > def options(heaps): > for i, heap in enumerate(heaps): > head = heaps[:i] > tail = heaps[i+1:] > yield from (head + [x] + tail for x in range(heap)) > > "yield from" is Python 3.3 syntax. If you're not using Python 3.3, > then that line could be replaced by: > > for x in range(heap): > yield head + [x] + tail > > Cheers, > Ian Perhaps range(heap) should be replaced by range(len(heap)) -- DaveA