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

Home » Public Forums » archive » Lousiest IDL code: my entry
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Lousiest IDL code: my entry [message #11960] Fri, 05 June 1998 00:00
mirko_vukovic is currently offline  mirko_vukovic
Messages: 50
Registered: January 1998
Member
In article <MPG.fe07069789b867d9897ce@news.frii.com>,
davidf@dfanning.com (David Fanning) wrote:

> P.S. I think we should have a contest to see who can write
> the lousiest IDL code. (Or the code which most resembles
> C code, which often amounts to the same thing.) Bonus points if
> the user can't figure out *what* it is suppose to do!

Here is my entry. I wrote it during the grad school days. A colleague of
mine barfed when he saw the indices a week or two later. I could not explain
to him what the code did. Mind you, I do write much more readable code now.

regards,

mirko


PRO GS_RGL,t,d,dt,ext=ext
;[doc]

; initialize
d2=fltarr(n_elements(d)) ; pointer array
dthi=t(1:*)-t ; time between extrema
iii=where(dthi lt dt,count)
if count eq 0 then return ; return if everything ok

; loop and mark data for deletion
for ii=0,count-1 do begin
if strupcase(ext) eq 'MAX' then md=min(d(iii(ii):iii(ii)+1),index) $
else md=max(d(iii(ii):iii(ii)+1),index)
i1=[iii(ii),iii(ii)+1]
i2=i1(index)
d2(i2)=1 ; mark data for deletion
endfor

; return only unmarked data
jjj=where(d2 ne 1)
d=d(jjj)
t=t(jjj)

; call again
GS_RGL,t,d,dt,ext=ext

return
end


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Stupidest IDL code: my entry
Next Topic: Re: Control-C and cleanup routine

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

Current Time: Sat Oct 11 03:56:11 PDT 2025

Total time taken to generate the page: 0.80114 seconds