function idx=firstValue(v) %testIt a test function to play with ideas % % takes a vector v and returns an index % % the definition is constantly changing as we % try out different ideas % % P. Conrad for CISC106 10/11/06 firstValue = v(1); for k = 1:length(v) if (v(k) == firstValue) % do nothing else 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