rfinch@caldwr.water.ca.gov (Ralph Finch) (03/16/91)
PV-Wave 3.02 on a Sun 4. Array operations are quite powerful in idl-wave and so different from other languages that I think I still don't fully understand them. Here is something that has me puzzled: a=[1,2,3,4,5] print,a([-1]) -> 1 print,a(-1) -> ERROR Why the difference? -- Ralph Finch 916-445-0088 rfinch@water.ca.gov ...ucbvax!ucdavis!caldwr!rfinch Any opinions expressed are my own; they do not represent the DWR
steve@bat.lle.rochester.edu (Steve Swales) (03/16/91)
In article <275@locke.water.ca.gov>, rfinch@caldwr.water.ca.gov (Ralph Finch) writes: > > PV-Wave 3.02 on a Sun 4. > > Array operations are quite powerful in idl-wave and so different from > other languages that I think I still don't fully understand them. > Here is something that has me puzzled: > > a=[1,2,3,4,5] > print,a([-1]) > -> 1 > print,a(-1) > -> ERROR > > Why the difference? Looks like a 'feature' to me. One explanation for it might be that one commonly will use this syntax for 'mapping' an array through a lookup table, and in this case it makes sense to have range checking for values off the end of the LUT and 'clamp' them to the end values... i.e.: lut=[0.1,0.5,0.75,0.9,0.95] values=[0,1,2,3,4,5,-1,11,4,3,2,7] print,lut(values) -> .100000 .500000 .750000 .900000 .950000 .950000 -> .100000 .950000 .950000 .900000 .750000 .950000 Isn't it fun to think up justifications for inconsistent program behavior... and you get lots of practice working with WAVE/IDL :-). -steve -- -------------------------------------------------------+"Come, Watson, come!" Steve Swales (716) 275-0265,-3857,-5101| he cried. "The game is steve@lle.rochester.edu (128.151.32.111)| afoot. Not a word! | Into your clothes and University of Rochester 250 East River Road| come!" S.H. Laboratory for Laser Energetics Rochester, NY 14623| 'The Abbey Grange'