function s=tostring(varargin)
% tostring - Tries to represent values as a sensible string
%
% tostring :: A -> string.
% tostring :: A, B -> string.
% etc.
%
% Multiple inputs are converted to comma-separated string.
	s=catsep(',',map(@tostr,varargin));
end
						
function s=tostr(x)
	if ischar(x), s=x;
	elseif isnumeric(x),
		sz=size(x);
		if prod(sz)<16, s=mat2str(x);
		else s=sprintf('%s[%s]',class(x),mat2str(sz)); end
	elseif isa(x,'function_handle'), s=func2str(x);
		if s(1)~='@', s=['@' s]; end
	elseif isa(x,'func'), s=tostring(x);
	else s=['obj:' class(x)];
	end
end

