annotate scripts/general/deal.m @ 20654:b65888ec820e draft default tip gccjit

dmalcom gcc jit import
author Stefan Mahr <dac922@gmx.de>
date Fri, 27 Feb 2015 16:59:36 +0100
parents 7503499a252b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
1 ## Copyright (C) 1998-2015 Ariel Tankus
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2 ##
4818
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
4 ##
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6714
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6714
diff changeset
8 ## your option) any later version.
4818
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
9 ##
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
14 ##
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6714
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6714
diff changeset
17 ## <http://www.gnu.org/licenses/>.
4818
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
18
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 7017
diff changeset
20 ## @deftypefn {Function File} {[@var{r1}, @var{r2}, @dots{}, @var{rn}] =} deal (@var{a})
6714
81a73cdd87c0 [project @ 2007-06-13 10:49:28 by dbateman]
dbateman
parents: 6046
diff changeset
21 ## @deftypefnx {Function File} {[@var{r1}, @var{r2}, @dots{}, @var{rn}] =} deal (@var{a1}, @var{a2}, @dots{}, @var{an})
4818
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
22 ##
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
23 ## Copy the input parameters into the corresponding output parameters.
20193
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
24 ##
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
25 ## If only a single input parameter is supplied, its value is copied to each
4818
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
26 ## of the outputs.
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
27 ##
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
28 ## For example,
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
29 ##
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
30 ## @example
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
31 ## [a, b, c] = deal (x, y, z);
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
32 ## @end example
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
33 ##
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
34 ## @noindent
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
35 ## is equivalent to
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
36 ##
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
37 ## @example
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
38 ## @group
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
39 ## a = x;
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
40 ## b = y;
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
41 ## c = z;
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
42 ## @end group
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
43 ## @end example
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
44 ##
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
45 ## @noindent
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
46 ## and
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
47 ##
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
48 ## @example
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
49 ## [a, b, c] = deal (x);
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
50 ## @end example
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
51 ##
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
52 ## @noindent
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
53 ## is equivalent to
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
54 ##
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
55 ## @example
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
56 ## a = b = c = x;
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
57 ## @end example
19101
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
58 ##
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
59 ## Programming Note: @code{deal} is often used with comma separated lists
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
60 ## derived from cell arrays or structures. This is unnecessary as the
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
61 ## interpreter can perform the same action without the overhead of a function
19186
0f9c5a15c8fa doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 19101
diff changeset
62 ## call. For example:
19101
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
63 ##
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
64 ## @example
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
65 ## @group
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
66 ## c = @{[1 2], "Three", 4@};
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
67 ## [x, y, z ] = c@{:@}
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
68 ## @result{}
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
69 ## x =
19186
0f9c5a15c8fa doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 19101
diff changeset
70 ##
19101
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
71 ## 1 2
19186
0f9c5a15c8fa doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 19101
diff changeset
72 ##
19101
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
73 ## y = Three
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
74 ## z = 4
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
75 ## @end group
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
76 ## @end example
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
77 ## @seealso{cell2struct, struct2cell, repmat}
4818
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
78 ## @end deftypefn
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
79
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
80 ## Author: Ariel Tankus
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
81 ## Author: Paul Kienzle and Etienne Grossman
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
82 ## Created: 13.11.98
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
83 ## Adapted-by: jwe
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
84
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
85 function [varargout] = deal (varargin)
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
86
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
87 if (nargin == 0)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5307
diff changeset
88 print_usage ();
4819
de3b34644549 [project @ 2004-03-05 04:57:07 by jwe]
jwe
parents: 4818
diff changeset
89 elseif (nargin == 1 || nargin == nargout)
4820
a436d388b041 [project @ 2004-03-05 05:58:37 by jwe]
jwe
parents: 4819
diff changeset
90 varargout(1:nargout) = varargin;
4818
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
91 else
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
92 error ("deal: nargin > 1 and nargin != nargout");
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
93 endif
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
94
ef6ae7349d59 [project @ 2004-03-04 22:10:45 by jwe]
jwe
parents:
diff changeset
95 endfunction
4819
de3b34644549 [project @ 2004-03-05 04:57:07 by jwe]
jwe
parents: 4818
diff changeset
96
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
97
4819
de3b34644549 [project @ 2004-03-05 04:57:07 by jwe]
jwe
parents: 4818
diff changeset
98 %!test
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
99 %! [a,b] = deal (1,2);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
100 %! assert (a, 1);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
101 %! assert (b, 2);
4819
de3b34644549 [project @ 2004-03-05 04:57:07 by jwe]
jwe
parents: 4818
diff changeset
102 %!test
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
103 %! [a,b] = deal (1);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
104 %! assert (a, 1);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
105 %! assert (b, 1);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
106
19101
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
107 %!error deal ()
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
108 %!error <nargin . 1 and nargin != nargout> y = deal (1, 2)
4fd271cd9b37 deal.m: Document using interpreter, rather than deal, for comma separated lists.
Rik <rik@octave.org>
parents: 17744
diff changeset
109