7017
|
1 ## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, |
|
2 ## 2005, 2006, 2007 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/>. |
920
|
19 |
3361
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} strcat (@var{s1}, @var{s2}, @dots{}) |
|
22 ## Return a string containing all the arguments concatenated. For example, |
3426
|
23 ## |
3361
|
24 ## @example |
|
25 ## @group |
|
26 ## s = [ "ab"; "cde" ]; |
|
27 ## strcat (s, s, s) |
|
28 ## @result{} "ab ab ab " |
|
29 ## "cdecdecde" |
|
30 ## @end group |
|
31 ## @end example |
|
32 ## @end deftypefn |
2697
|
33 |
2314
|
34 ## Author: jwe |
|
35 |
6138
|
36 function st = strcat (varargin) |
920
|
37 |
6138
|
38 if (nargin < 1) |
6046
|
39 print_usage (); |
6138
|
40 elseif (! iscellstr (varargin)) |
|
41 error ("strcat: all arguments must be strings"); |
920
|
42 endif |
|
43 |
6145
|
44 unwind_protect |
|
45 tmp = warning ("query", "Octave:empty-list-elements"); |
|
46 warning ("off", "Octave:empty-list-elements"); |
|
47 st = [varargin{:}]; |
|
48 unwind_protect_cleanup |
|
49 warning (tmp.state, "Octave:empty-list-elements"); |
|
50 end_unwind_protect |
920
|
51 |
|
52 endfunction |
6138
|
53 |
|
54 ## test the dimensionality |
|
55 ## 1d |
|
56 %!assert(strcat("ab ", "ab "), "ab ab ") |
|
57 ## 2d |
|
58 %!assert(strcat(["ab ";"cde"], ["ab ";"cde"]), ["ab ab ";"cdecde"]) |