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

Home » Public Forums » archive » LIST extensions
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
LIST extensions [message #73973] Tue, 14 December 2010 13:51 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Hello,

Sorry to keep flogging this particular topic, but I'm currently up to my eyes in adapting some code from using pointers
to using lists (partly for curiosity, partly to avoid nested pointer dereferencing), and I've found the very simple
methods below to be useful in dealing with the "is it empty?", "are there nulls in the list?" etc type of questions I've
been asking here.

Comments?

cheers,

paulv


;+
; NAME:
; List::Empty
;
; PURPOSE:
; The List::Empty function method return TRUE if a list contains
; no elements, FALSE otherwise.
;
; CALLING SEQUENCE:
; result = Obj->[List::]Empty()
;-
FUNCTION List::Empty
RETURN, N_ELEMENTS(self) EQ 0
END


;+
; NAME:
; List::Length
;
; PURPOSE:
; The List::Length function method returns the number of
; elements in a list.
;
; CALLING SEQUENCE:
; result = Obj->[List::]Length()
;-
FUNCTION List::Length
RETURN, N_ELEMENTS(self)
END


;+
; NAME:
; List::n_Items
;
; PURPOSE:
; The List::n_Items function method returns the number of
; non-null elements in a list.
;
; CALLING SEQUENCE:
; result = Obj->[List::]n_Items()
;-
FUNCTION List::n_Items
idx = WHERE(self NE !NULL, count)
RETURN, count
END


;+
; NAME:
; List::Compact
;
; PURPOSE:
; The List::Compact function method returns a copy of a list
; with all null elements removed.
;
; CALLING SEQUENCE:
; result = Obj->[List::]Compact()
;-
FUNCTION List::Compact
idx = WHERE(self NE !NULL, count)
RETURN, ( count GT 0 ) ? self[idx] : LIST()
END
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: LIST extensions
Next Topic: screen capture of xplot3d

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

Current Time: Thu Oct 09 21:13:31 PDT 2025

Total time taken to generate the page: 0.32288 seconds