%
%	Search for an element in the list and return its index.
%

function search(list: array 1..* of string, key: string, N: int): int

%
%	Linear search.  Find element i in range 1..N such that
%	list(i) = key, if key exists in list.
%
%	If so, return i, otherwise return 0.

    var i := N

    loop
	exit when i <= 0 or list(i) = key
	i := i-1
    end loop

    result i
end search
