has and Dethe wrote:
>def bool2cm0k(lst):
> """Converts a list of booleans to a CMYK color string,
> e.g. [True, False, False, True] to 'C00K'
> """
> return ''.join([b and c or '0' for b, c in zip(lst, 'CMYK')])
>
>def cm0k2bool(s):
> """Converts a CMYK color string to a l
[EMAIL PROTECTED] wrote:
"".join(map(lambda x,y: {True:x, False:"0"}[y], _cmykMap,
>[True, False, True, True]))
>'C0YK'
>but I'd break that down into a selector function (rather than a
>lambda) or something to make it readable, since it's way too far on
>the lisp side of things as far as exp
On 1-Feb-05, at 4:47 PM, has wrote:
Henning Hraban Ramm wrote:
I'm looking for a better algorithm...
This is probably as terse as it gets:
[snip]
# zip() isn't needed in this direction
def cm0k2bool(s):
return [x != '0' for x in s]
--Dethe
"The law I sign today directs new funds and new focus t
Henning Hraban Ramm wrote:
I'm looking for a better algorithm...
This is probably as terse as it gets:
def bool2cm0k(lst):
"""Converts a list of booleans to a CMYK color string,
e.g. [True, False, False, True] to 'C00K'
"""
return ''.join([b and c or '0' for b, c in zip(lst, 'CM
It's certainly one of the things map+lambda are for
>>> "".join(map(lambda x,y: {True:x, False:"0"}[y], _cmykMap, [True, False,
>>> True, True]))
'C0YK'
but I'd break that down into a selector function (rather than a
lambda) or something to make it readable, since it's way too far on
the lisp si
Hi there!
I'm looking for a better algorithm...
In a print project I must know if some page needs every CMYK separation or just
some;
I keep this info in a boolean list like [True, True, False, True] for C,M,K (no
Y plate).
But our workflow database needs a string like "CM0K" (plate letter or z