Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!feed.xsnews.nl!border-2.ams.xsnews.nl!xlned.com!feeder1.xlned.com!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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:Python': 0.05; 'python': 0.09; '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; 'header:In-Reply-To:1': 0.25; 'looks': 0.26; 'message- id:@mail.gmail.com': 0.27; 'tail': 0.29; 'fri,': 0.30; 'could': 0.32; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'nov': 0.35; 'replaced': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'next': 0.35; 'anything': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'more': 0.63; '(head': 0.84; 'to:name:python': 0.84 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=hwlDk3hNwos6v3IpZfeqF6tbUhtLppq/qfLF6cVBUUU=; b=OgJS8LJe+R4A1rWBlXNaJ1TqLf5xGBvBjvJrG8M70jTGso/e1nWq2RLR+600eXTD70 dc700ftaTMQK2edFkvzkf1bSHA8K9Jvh5xvm9lbvrsrXgVw2D8NG/O7uTouPYtbMn6ko Oyv8Aqpy4QLNyqOO/I6g1k1xZEYvLfAl+LcqzoD28pIjz6GBeWC1mBSA92Q3fGXh2zAW z94z6Qky8pewIQcRllVJAAJxftgF/a9jrdA7ypQKyWZhnZwBUZj4DjFRoJJJpmFfRPAc fvoWQcj/DN2f5tMHE4FxWBv9qBljZb6eMVHYD5/3ecsPfSPQIso0aro3QcL1bSLlG1y5 ZMsQ== MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Fri, 2 Nov 2012 15:40:53 -0600 Subject: Re: Haskell -> Python To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351892486 news.xs4all.nl 6950 [2001:888:2000:d::a6]:50158 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32661 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