function idx=firstChange(v)
%firstChange return idx of first val different from preceding vals
%
% fill this in with examples later @@@
%
% P. Conrad for CISC106 10/11/06

firstValue = v(1);
for k = 1:length(v)

  if (v(k) ~= firstValue)
    idx = k;
    return;
  end;

end;

% Postcondition: every value must be equal to
% the firstValue.  Otherwise, I would have returned already,
% since I tested v(k) against firstValue for every value of k

idx = 0;
end
