Mercurial > hg > octave-avbm
annotate scripts/deprecated/complement.m @ 10821:693e22af08ae
Grammarcheck documentation of m-files
Add newlines between @item fields for readability.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 26 Jul 2010 21:25:36 -0700 |
parents | f322d72d482c |
children | fd0a3ac60b0e |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 1994, 1996, 1997, 1999, 2000, 2004, 2005, 2006, 2007, |
2 ## 2008, 2009 John W. Eaton | |
2313 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
2313 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
2303 | 19 |
3368 | 20 ## -*- texinfo -*- |
21 ## @deftypefn {Function File} {} complement (@var{x}, @var{y}) | |
22 ## Return the elements of set @var{y} that are not in set @var{x}. For | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10040
diff
changeset
|
23 ## example: |
3426 | 24 ## |
3368 | 25 ## @example |
26 ## @group | |
27 ## complement ([ 1, 2, 3 ], [ 2, 3, 5 ]) | |
28 ## @result{} 5 | |
29 ## @end group | |
30 ## @end example | |
8898
ca032de5fbf2
Remove references to deprecated function create_set.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8887
diff
changeset
|
31 ## @seealso{union, intersect, unique} |
3408 | 32 ## @end deftypefn |
3368 | 33 |
2314 | 34 ## Author: jwe |
35 | |
10040 | 36 ## Deprecated in version 3.2 |
37 | |
2311 | 38 function y = complement (a, b) |
559 | 39 |
10040 | 40 persistent warned = false; |
41 if (! warned) | |
42 warned = true; | |
43 warning ("Octave:deprecated-function", | |
44 "complement is obsolete and will be removed from a future version of Octave, please use setdiff instead"); | |
45 endif | |
46 | |
904 | 47 if (nargin != 2) |
6046 | 48 print_usage (); |
559 | 49 endif |
50 | |
904 | 51 if (isempty (a)) |
8887 | 52 y = unique (b); |
904 | 53 elseif (isempty (b)) |
559 | 54 y = []; |
55 else | |
8887 | 56 a = unique (a); |
57 b = unique (b); | |
559 | 58 yindex = 1; |
904 | 59 y = zeros (1, length (b)); |
60 for index = 1:length (b) | |
61 if (all (a != b (index))) | |
559 | 62 y(yindex++) = b(index); |
63 endif | |
64 endfor | |
65 y = y(1:(yindex-1)); | |
66 endif | |
67 | |
68 endfunction | |
7411 | 69 |
70 %!assert(all (all (complement ([1, 2, 3], [3; 4; 5; 6]) == [4, 5, 6]))); | |
71 | |
72 %!assert(all (all (complement ([1, 2, 3], [3, 4, 5, 6]) == [4, 5, 6]))); | |
73 | |
74 %!assert(isempty (complement ([1, 2, 3], [3, 2, 1]))); | |
75 | |
76 %!error complement (1); | |
77 | |
78 %!error complement (1, 2, 3); | |
79 |