function s = subset_next ( s )

%*****************************************************************************80
%
%% subset_next() returns the next subset of n items.
%
%  Discussion:
%
%    The subset is represented as a vector of binary digits.
%    The subsets are listed in numerical order.
%    After the last subset is returned, the sequence begins again at 0.
%
%  Example:
%
%    [ 0, 0, 0 ]
%    [ 0, 0, 1 ]
%    [ 0, 1, 0 ]
%    [ 0, 1, 1 ]
%    [ 1, 0, 0 ]
%    [ 1, 0, 1 ]
%    [ 1, 1, 0 ]
%    [ 1, 1, 1 ]
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 November 2024
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer s[n]: the current subset.
%
%  Output:
%
%    integer s[n]: the next subset.
%
  n = length ( s );
%
%  Starting at the last index, add 1, and if necessary, carry to the left.
%
  for i = n : -1 : 1

    if ( s(i) == 0 )
      s(i) = 1;
      break;
    else
      s(i) = 0;
    end

  end

  return
end

