function index = subset_to_rank ( s )

%*****************************************************************************80
%
%% subset_to_rank() returns the rank of a subset().
%
%  Discussion:
%
%    The subset is described by a binary vector of n digits.
%    The units digit is the last one.
%    Reading from right to left, we add selected powers of 2.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 November 2024
%
%  Author:
%
%    John Burkardt
%
  n = length ( s );

  index = 0;
  power2 = 1;
  for i = n : -1 : 1
    index = index + s(i) * power2;
    power2 = power2 * 2;
  end

  return
end

