[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "clamping" an array to a maximum value?
- Subject: Re: "clamping" an array to a maximum value?
- From: Craig Markwardt <craigmnet(at)astrog.physics.wisc.edu>
- Date: 22 Dec 1998 10:40:37 -0600
- Newsgroups: comp.lang.idl-pvwave
- Organization: U. Wisc. Madison Physics -- Compact Objects
- References: <75l3vi$nit$1@nnrp1.dejanews.com> <367E2717.F0FD5F90@Ivory.de><367E6666.D52494DD@io.harvard.edu> <367E945C.A1959EB9@Ivory.de><MPG.10e862e83fcba93a9896ba@news.frii.com><367FC04A.2220FE@io.harvard.edu>
- Reply-To: craigmnet(at)astrog.physics.wisc.edu
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:13213
Martin Schultz <mgs@io.harvard.edu> writes:
> Yup,
>
> that's what I really intended to say/write. BTW: How about a "last
> element" operator? I very often need something like
> subdata = data[*,0:n_elements(data[0,*])-1]
> which is not very aesthetic ;-) is it? It would just be great if one
> could write something like
> subdata = data[*,0:(*)-1] or anything with a similar short syntax
> In this case the parantheses would serve to distinguish between "all
> elements" and "last element". That's probably a little dangerous. Anyone
> with a better idea?
Yes, yes, a billion times yes! A billion is about the number of times
I could have used this capability.
Some present-day scripting languages allow you to supply negative
subscripts, to indicate indexing from the end rather than the front of
the array. data[-1] would indicate the last element, data[-2] the
second to last, etc. Powerful, but maybe *too* powerful.
Craig
--
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@astrog.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------