Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28979
| Date | 2012-09-12 16:55 +0100 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Boolean function on variable-length lists |
| References | <f9d9dfa2-71c6-4b47-9d0a-e6f59c8ab818@googlegroups.com> <qotwqzzjswb.fsf@ruuvi.it.helsinki.fi> <c90042ac-d6b8-4fe2-8174-3de1462a3537@googlegroups.com> <qotsjanjrag.fsf@ruuvi.it.helsinki.fi> <50509372.3080001@seehart.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.569.1347465338.27098.python-list@python.org> (permalink) |
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)
>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Boolean function on variable-length lists Libra <librarama@gmail.com> - 2012-09-12 05:48 -0700
Re: Boolean function on variable-length lists Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-09-12 16:02 +0300
Re: Boolean function on variable-length lists Tim Chase <python.list@tim.thechases.com> - 2012-09-12 08:18 -0500
Re: Boolean function on variable-length lists Libra <librarama@gmail.com> - 2012-09-12 06:19 -0700
Re: Boolean function on variable-length lists Libra <librarama@gmail.com> - 2012-09-12 06:33 -0700
Re: Boolean function on variable-length lists Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-09-12 16:37 +0300
Re: Boolean function on variable-length lists Ken Seehart <ken@seehart.com> - 2012-09-12 06:51 -0700
Re: Boolean function on variable-length lists Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-12 15:29 +0100
Re: Boolean function on variable-length lists MRAB <python@mrabarnett.plus.com> - 2012-09-12 16:55 +0100
Re: Boolean function on variable-length lists Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-12 13:11 +0000
Re: Boolean function on variable-length lists Libra <librarama@gmail.com> - 2012-09-12 06:25 -0700
csiph-web