6138
|
1 ## Copyright (C) 1996, 1997, 2006 John W. Eaton |
2313
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
2313
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
920
|
18 |
3361
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} strcat (@var{s1}, @var{s2}, @dots{}) |
|
21 ## Return a string containing all the arguments concatenated. For example, |
3426
|
22 ## |
3361
|
23 ## @example |
|
24 ## @group |
|
25 ## s = [ "ab"; "cde" ]; |
|
26 ## strcat (s, s, s) |
|
27 ## @result{} "ab ab ab " |
|
28 ## "cdecdecde" |
|
29 ## @end group |
|
30 ## @end example |
|
31 ## @end deftypefn |
2697
|
32 |
2314
|
33 ## Author: jwe |
|
34 |
6138
|
35 function st = strcat (varargin) |
920
|
36 |
6138
|
37 if (nargin < 1) |
6046
|
38 print_usage (); |
6138
|
39 elseif (! iscellstr (varargin)) |
|
40 error ("strcat: all arguments must be strings"); |
920
|
41 endif |
|
42 |
6145
|
43 unwind_protect |
|
44 tmp = warning ("query", "Octave:empty-list-elements"); |
|
45 warning ("off", "Octave:empty-list-elements"); |
|
46 st = [varargin{:}]; |
|
47 unwind_protect_cleanup |
|
48 warning (tmp.state, "Octave:empty-list-elements"); |
|
49 end_unwind_protect |
920
|
50 |
|
51 endfunction |
6138
|
52 |
|
53 ## test the dimensionality |
|
54 ## 1d |
|
55 %!assert(strcat("ab ", "ab "), "ab ab ") |
|
56 ## 2d |
|
57 %!assert(strcat(["ab ";"cde"], ["ab ";"cde"]), ["ab ab ";"cdecde"]) |