[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: pred & succ ?*From*: Martin Schultz <martin.schultz(at)dkrz.de>*Date*: Mon, 13 Nov 2000 09:40:58 +0100*Newsgroups*: comp.lang.idl-pvwave*Organization*: Max-Planck-Institut fuer Meteorologie, Hamburg*References*: <8uo0rm$5q7$1@nnrp1.deja.com>*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:22140

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 [[ [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[

**Follow-Ups**:**Re: pred & succ ?***From:*Andrew

**References**:**pred & succ ?***From:*Andrew

- Prev by Date:
**XYOUTS documentation error?** - Next by Date:
**projecting a PLOT onto wall of SURACE** - Prev by thread:
**pred & succ ?** - Next by thread:
**Re: pred & succ ?** - Index(es):