Mercurial > hg > octave-lojdl
changeset 4819:de3b34644549
[project @ 2004-03-05 04:57:07 by jwe]
author | jwe |
---|---|
date | Fri, 05 Mar 2004 04:57:07 +0000 |
parents | ef6ae7349d59 |
children | a436d388b041 |
files | scripts/ChangeLog scripts/general/deal.m |
diffstat | 2 files changed, 12 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,6 +1,7 @@ 2004-03-04 John W. Eaton <jwe@bevo.che.wisc.edu> * general/deal.m: New function. + Add tests from Paul Kienzle. 2004-03-03 Stefan van der Walt <stefan@sun.ac.za>
--- a/scripts/general/deal.m +++ b/scripts/general/deal.m @@ -66,15 +66,19 @@ if (nargin == 0) usage ("[a, b, c, d] = deal (x, y, z, a)"); - elseif (nargin == 1) - v = varargin{1}; - for i = 1:nargout - varargout{i} = v; - endfor - elseif (nargin == nargout) - varargout = varargin; + elseif (nargin == 1 || nargin == nargout) + varargout(:) = varargin; else error ("deal: nargin > 1 and nargin != nargout"); endif endfunction + +%!test +%! [a,b]=deal(1,2); +%! assert(a,1); +%! assert(b,2); +%!test +%! [a,b]=deal(1); +%! assert(a,1); +%! assert(b,1);