		function find_equal_in_pair,x,y,error=error

error=0
ind=-1

Nx=n_elements(x)
Ny=n_elements(y)

N=Nx > Ny

x1=x(sort([x]))
y1=y(sort([y]))

index=intarr(Nx,Ny)-1

for j=0,Ny-1 do index(0,j)=where(x1 eq y1(j))

temp=where(index ge 0)
if temp(0) eq -1 then goto, L1

ind=index(temp)
ind=ind(sort(ind))
ind=ind(uniq(ind))

L1:
	if ind(0) lt 0 then begin
error=1
return,-1
	endif

return,x1(ind)

	end



	function find_equal,x0,x1,x2,x3,error=error

;+	Finds coinciding elements in two arrays
;-

N=n_params()
Output=0
error=0
ind=-1


	CASE N OF

2:	Output=find_equal_in_pair(x0,x1,error=error)

3:	begin
Output=find_equal_in_pair(x0,x1,error=error)
	if error then goto, L2
Output=find_equal_in_pair(x2,Output,error=error)
	if error then goto, L2
	end

4:	begin
Output=find_equal_in_pair(x0,x1,error=error)
	if error then goto, L2
Output=find_equal_in_pair(x2,Output,error=error)
	if error then goto, L2
Output=find_equal_in_pair(x3,Output,error=error)
	if error then goto, L2
	end

ELSE:	begin
print,'Number of arguments must be from 2 to 4.'
error=1
	end

	ENDCASE



L2:
	if error ne 1 then goto, L3

Output=-1
print,'Nothing coincides'
error=1

L3:

return,Output

end

