;+ ; NAME: ; ismember ; PURPOSE: (one line) ; return 1 if an element is a member of an array ; DESCRIPTION: ; ; CATEGORY: ; Util ; CALLING SEQUENCE: ; ismember, elem, list ; INPUTS: ; element - the element to be tests ; list - the list to be checked if member is an element of ; OPTIONAL INPUT PARAMETERS: ; none ; KEYWORD INPUT PARAMETERS: ; none ; KEYWORD OUTPUT PARAMETERS: ; none ; OUTPUTS: ; byte: 0 if elemen is not a member, 1 if it is ; COMMON BLOCKS: ; None ; SIDE EFFECTS: ; RESTRICTIONS: ; None ; PROCEDURE: ; MODIFICATION HISTORY: ; 2006 July 23 Leslie Young SwRI ;- function ismember, elem, list if isarray(elem) then begin n = n_elements(elem) res = byte(fix(elem)) ; to get the right dimensions. ; Fix first, in case res is a string. for i = 0L, n-1 do res[i] = (total(elem[i] eq list) gt 0) return, res endif else begin return, total(elem eq list) gt 0 endelse end