function counter ( )

%*****************************************************************************80
%
%% counter() simply reports how many times it has been called.
%
%  Discussion:
%
%    If you can get a function like this to work, you have made a good
%    start at implementing persistent data.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    12 May 2021
%
%  Author:
%
%    John Burkardt
%
  persistent calls
%
%  calls starts out as an empty variable, and we have to initialize it once.
%
  if ( isempty ( calls ) )
    calls = 0;
  end
%
%  Increment calls.
%
  calls = calls + 1;
%
%  Simply report the current value to the user.
%
  fprintf ( 1, '  counter() has been called %d times\n', calls );

  return
end

