comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: conditional operator
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: conditional operator [message #63575] Fri, 14 November 2008 14:31
greg.addr is currently offline  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 Go to previous message
Michael Galloy is currently offline  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 Go to previous message
Wox is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: type conversion string -> float
Next Topic: ncdf string array dimension

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:40:04 PDT 2025

Total time taken to generate the page: 0.00536 seconds