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

Home » Public Forums » archive » Re: pred & succ ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: pred & succ ? [message #22457 is a reply to message #22450] Mon, 13 November 2000 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Andrew wrote:
>
> Dear C.l.i-p,
>
> In Pascal (and probably in other high-level languages,
> but I don't know), there are built-in functions PRED(x)
> & SUCC(x), where x is any ordinal-type variable.
>
> e.g.: PRED(1)=0
> SUCC(2)=3
> PRED(TRUE)=FALSE
>
> etc., etc.
>
> Is there anything like this in IDL?
>
> -- Andrew
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

FUNCTION pred, x
RETURN, x-1
END
FUNCTION succ, x
RETURN, x+1
END

But is that really worth it? You won't be able to construct
pred(false) for there is no distinct "false" in IDL. But this is
actually a nice little "Denksportaufgabe" (although I am sure you can
find a solution on some webpage, too): How do you construct a reliable
complement of a variable that represents a boolean?
Hints:
- should accept any (numerical) type (ok, maybe not complex ;-)
- variable type should be preserved
- 0 is false, everything else true (how about 1.e-30? - probably best
to define an "eps"); in output, "true" should be 1
- should not be constrained to scalars (IF(...) won't work)

Thanks to RSI for not providing us with a dedicated "logical" or
"boolean" type. Otherwise this would be too trivial ;-)

Cheers,
Martin


--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: trouble with color table on NT
Next Topic: tick label distance from axis in SURFACE

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

Current Time: Sat Dec 06 05:35:10 PST 2025

Total time taken to generate the page: 0.00216 seconds