function cv2 = chvec_reduce ( cv1 )

%*****************************************************************************80
%
%% chvec_reduce() reduces strings of the same character to a single instance.
%
%  Example:
%
%    Input:
%
%      cv1 = ( 'A', 'L', 'L', 'I', 'F', 'E', 'E', 'L' ).
%
%    Output:
%
%      cv2 = ( 'A', 'L', 'I', 'F', 'E', 'L' ).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 May 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    character cv1(n1): the vector to be reduced.
%
%  Output:
%
%    character cv2(n2): the reduced vector.
%
  n1 = length ( cv1 );

  n2 = 0;
  cv2 = '';

  if ( n1 < 1 )
    return
  end

  n2 = 1;
  cv2(n2) = cv1(1);
  co = cv1(1);

  for i = 2 : n1
    if ( cv1(i) ~= co )
      n2 = n2 + 1;
      cv2(n2) = cv1(i);
    end
    co = cv1(i);
  end

  return
end
