Re: kind of bewildered [message #26745] |
Mon, 24 September 2001 08:34 |
John-David T. Smith
Messages: 384 Registered: January 2000
|
Senior Member |
|
|
Lasse Clausen wrote:
>
> Lasse Clausen wrote:
>>
>> I have the following code:
>> IDL> .run
>> - data=['12.04','13.04','14.04']
>> - A= FLOAT(DATA[WHERE(DATA EQ FLOAT('13.04'))])
>> - print,size(FINDGEN(10.)+A)
>> - end
>> % Compiled module: $MAIN$.
>> 1 1 4 1
>>
>> Why the hack do I not get an vector of size 10?!
>
> Ok, i noticed that A is not a scalar but a array with just one entry.
> can i 'cenvert' such an one-dimensional array into a scalar?
For those of you feeling similarly overwhelmed by the subtle distinction
between scalars and 1-D unit length arrays, be consoled by the following
words of wisdom from one of RSI's ace designers:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
If I were designing IDL over, there would be no scalars, just
arrays of various dimensionality. 1-element arrays would use the
IDL scalar implementation internally for efficiency, but the
user would not see this. Too bad though --- IDL already exists,
and this ship sailed long before I became involved with it...
>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
JD
|
|
|
Re: kind of bewildered [message #26746 is a reply to message #26745] |
Mon, 24 September 2001 07:58  |
Jaco van Gorkom
Messages: 97 Registered: November 2000
|
Member |
|
|
Lasse Clausen wrote:
> Ok, i noticed that A is not a scalar but a array with just one entry.
> can i 'cenvert' such an one-dimensional array into a scalar?
A = A[0] should do the trick.
More fancy: if n_elements(A) eq 1 then A = A[0]
Jaco
|
|
|