Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.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; 'fails.': 0.09; 'def': 0.10; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'lambda': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:variable': 0.16; 'wrote:': 0.17; 'putting': 0.20; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'received:192.168.1.3': 0.29; 'received:84': 0.32; 'subject:lists': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'why': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'subject:-': 0.40; 'header:Reply-To:1': 0.68; 'soon': 0.70; 'reply-to:no real name:2**0': 0.72; 'reply-to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=IekFqBWa c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=AAvI7MrX_rgA:10 a=yFEmK0Gn6HIA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=DfiHFX6KCwAA:10 a=ylmotpYq-j5qwBnaJhMA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Wed, 12 Sep 2012 16:55:40 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Boolean function on variable-length lists References: <50509372.3080001@seehart.com> In-Reply-To: <50509372.3080001@seehart.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347465338 news.xs4all.nl 6913 [2001:888:2000:d::a6]:40497 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28979 On 12/09/2012 14:51, Ken Seehart wrote: > Putting a few of peoples ideas together... > > > gt = lambda x: lambda y: x>y > eq = lambda x: lambda y: x==y > > def constrain(c,d): > return all({f(x) for f, x in zip(c, d)}) > If you're going to use 'all', why use a set? return all(f(x) for f, x in zip(c, d)) This will stop as soon as a constraint fails. > constraints = [gt(2), eq(1)] > data0 = [1,1] > data1 = [3,1] > > print constrain(constraints, data0) > print constrain(constraints, data1) >