Mercurial > hg > octave-nkf
annotate scripts/set/union.m @ 559:4e826edfbc56
[project @ 1994-07-25 22:18:28 by jwe]
Initial revision
author | jwe |
---|---|
date | Mon, 25 Jul 1994 22:19:05 +0000 |
parents | |
children | 3470f1e25a79 |
rev | line source |
---|---|
559 | 1 function y = union(a,b) |
2 | |
3 # usage: union(a,b) | |
4 # | |
5 # Returns the union of sets a and b. | |
6 # | |
7 # See - create_set, intersection, complement | |
8 | |
9 if (nargin != 2) | |
10 error("usage: union(a,b)"); | |
11 endif | |
12 | |
13 if(isempty(a)) | |
14 y = create_set(b); | |
15 elseif(isempty(b)) | |
16 y = create_set(a); | |
17 else | |
18 [nra, nca] = size(a); | |
19 a = reshape(a,1,nra*nca); | |
20 [nrb, ncb] = size(b); | |
21 b = reshape(b,1,nrb*ncb); | |
22 y = create_set([a, b]); | |
23 endif | |
24 | |
25 endfunction |