; function UNIQ_RANGE, ARRAY, IDX ; Check the arguments. s = size(ARRAY) if (s[0] lt 2) then return, 0 ;A scalar or not 2xn if n_params() ge 2 then begin ;IDX supplied? q0 = array[0,idx] q1 = array[1,idx] indices = where( (q0 ne shift(q0,-1)) or $ (q1 ne shift(q1,-1)), count) if (count GT 0) then return, idx[indices] $ else return, n_elements(q0[0,*])-1 endif else begin indices = where( (array[0,*] ne shift(array[0,*], -1)) or $ (array[1,*] ne shift(array[1,*], -1)), count) if (count GT 0) then return, indices $ else return, n_elements(ARRAY)-1 endelse end