Re: conditional operator [message #63575] |
Fri, 14 November 2008 14:31 |
greg.addr
Messages: 160 Registered: May 2007
|
Senior Member |
|
|
> I don't see how that would be more elegant than e.g.
> threshold = (image gt z) -1b
I agree that conciseness is elegant but, to me at least, the intent of
that kind of expression is less apparent. Clarity is also an element
of elegance.
regards,
Greg
|
|
|
Re: conditional operator [message #63579 is a reply to message #63575] |
Fri, 14 November 2008 09:23  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On Nov 14, 3:14 am, greg.a...@googlemail.com wrote:
> It seems odd to me that you can't apply the conditional operator "?"
> to an array:
>
> threshold = (image gt z) ? 0b:255b
>
> It's not hard to find another way, but this would be more elegant.
Yes, I agree. I've wanted a vectorized ?: operator for a while. I
suppose the reason is that the "cond" in:
if cond then statement
must be a scalar, but it doesn't seem like ?: has the same
restrictions of an IF statement.
Also, vectorized versions of ~, &&, and || would be nice.
Mike
--
www.michaelgalloy.com
Tech-X Corporation
Associate Research Scientist
|
|
|
Re: conditional operator [message #63586 is a reply to message #63579] |
Fri, 14 November 2008 05:16  |
Wox
Messages: 184 Registered: August 2006
|
Senior Member |
|
|
On 14 nov, 11:14, greg.a...@googlemail.com wrote:
> It seems odd to me that you can't apply the conditional operator "?"
> to an array:
>
> threshold = (image gt z) ? 0b:255b
>
> It's not hard to find another way, but this would be more elegant.
>
> cheers,
> Greg
I don't see how that would be more elegant than e.g.
threshold = (image gt z) -1b
|
|
|