function track = walker_1d ( n )

%% WALKER_1D takes a random walk on [-N,+N].
%
%  At time K = 1, a walker starts at x = 0.
%  At each new time K, the walker randomly steps to x-1 or x+1.
%  The walker finished when reaching -N or +N.
%
%  Input, N, the limits of the walk.
%
%  Output, TRACK(*), a list of the successive locations of the walker,
%  including the starting point.
%

%
%  Initialize.
%
  x = 0;
  k = 1;
  track(k) = x;

  while ( abs ( x ) < n )

    i = randi ( [ 1, 2 ] );

    if ( i == 1 )
      x = x - 1;
    else
      x = x + 1;
    end

    k = k + 1;
    track(k) = x;

  end

  return
end
