On 1/4/11 12:44 PM, Manfred_Nowak wrote:
Andrei Alexandrescu wrote:
Since a few releases ago
upps. sorry for not reading the docs.
-manfred
BTW I think the rgb2cmyk implementation in Higher Order Perl (which I
copied) is a bit convoluted. A simplified version is:
ubyte[4] rgb2cmyk(ubyte[3] rgb)
{
immutable m = max(rgb[0], rgb[1], rgb[2]);
return [ cast(ubyte)(m - rgb[0]), cast(ubyte)(m - rgb[1]),
cast(ubyte)(m - rgb[2]), ~m ];
}
Two nice typing touches: max does not necessitate a cast because it's
implemented to return ubyte for ubytes, and ~m also doesn't need a cast
thanks to value range propagation.
I don't know how to get rid of the remaining casts.
Andrei