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.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.05; 'case.': 0.05; 'python': 0.09; 'preferable': 0.09; 'def': 0.10; '3.3,': 0.16; '[x]': 0.16; 'heap': 0.16; 'syntax.': 0.16; 'wrote:': 0.17; 'yield': 0.17; 'latter': 0.22; 'header:In-Reply- To:1': 0.25; 'looks': 0.26; 'message-id:@mail.gmail.com': 0.27; 'tail': 0.29; 'fri,': 0.30; 'received:209.85.215.46': 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; 'think': 0.40; 'more': 0.63; 'fact,': 0.69; '(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=6/KizKquHBQj4WV+4gl/UIHx2d1ocw8dIAIypmV4I2w=; b=cHBS/ZiK22fBGiELrr3q+jDKTxps5U8JHP0MR/TDW+blqpvk3GO4ayVxMYuVWWA4DY bFRSJYzVprePkP6GvjU7FsYwqO/uoO/KKDo8M0ILXqdHiH5NiwVPI0qcOR/47x7KrZof D83DELmf9y6uugJUL97aZrWxUpjpmP9UbwgcUTyAsaRcQz9723jRs8/ghuqvEdXdWqex baJKT8ZqHmsJawOBN8I3oPAb9KRHe7sUWmRUMf85OQK5AQQcjmOtjHWt2DDIEpXPIyRj u4FmVUPRRHB+KmMYv3RTCAjCWFpYdauqUvGsQLb3iyRiF4do2IywXWa7yV7T51uaGO2R YP3Q== MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Fri, 2 Nov 2012 15:46:45 -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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351892837 news.xs4all.nl 6925 [2001:888:2000:d::a6]:53307 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32662 On Fri, Nov 2, 2012 at 3: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 In fact, the more that I look at it, the more that I think the latter might be preferable in any case.