annotate scripts/strings/isstring.m @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents 7854d5752dd2
children 83f9f8bda883
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
3 ## Copyright (C) 2017-2022 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
24474
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
7 ##
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
8 ## This file is part of Octave.
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24474
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
24474
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24474
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
24474
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
13 ## (at your option) any later version.
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
14 ##
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
18 ## GNU General Public License for more details.
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
19 ##
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24474
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
24474
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
25
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
26 ## -*- texinfo -*-
25039
40a65b30fadf maint: Match variable names in documentation to those in function prototype.
Rik <rik@octave.org>
parents: 24985
diff changeset
27 ## @deftypefn {} {} isstring (@var{s})
40a65b30fadf maint: Match variable names in documentation to those in function prototype.
Rik <rik@octave.org>
parents: 24985
diff changeset
28 ## Return true if @var{s} is a string array.
24474
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
29 ##
24985
d85b2485af9e doc: grammarcheck m-files ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24634
diff changeset
30 ## A string array is a data type that stores strings (row vectors of
d85b2485af9e doc: grammarcheck m-files ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24634
diff changeset
31 ## characters) at each element in the array. It is distinct from character
d85b2485af9e doc: grammarcheck m-files ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24634
diff changeset
32 ## arrays which are N-dimensional arrays where each element is a single 1x1
d85b2485af9e doc: grammarcheck m-files ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24634
diff changeset
33 ## character. It is also distinct from cell arrays of strings which store
d85b2485af9e doc: grammarcheck m-files ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24634
diff changeset
34 ## strings at each element, but use cell indexing @samp{@{@}} to access
d85b2485af9e doc: grammarcheck m-files ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24634
diff changeset
35 ## elements rather than string arrays which use ordinary array indexing
d85b2485af9e doc: grammarcheck m-files ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24634
diff changeset
36 ## @samp{()}.
24474
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
37 ##
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
38 ## Programming Note: Octave does not yet implement string arrays so this
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
39 ## function will always return false.
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
40 ## @seealso{ischar, iscellstr, isfloat, isinteger, islogical, isnumeric, isa}
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
41 ## @end deftypefn
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
42
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
43 function retval = isstring (s)
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
44
28891
de5f2f9a64ff maint: Use same coding style when checking for a minimum of 1 input.
Rik <rik@octave.org>
parents: 28886
diff changeset
45 if (nargin < 1)
24474
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
46 print_usage ();
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
47 endif
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
48
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
49 retval = false;
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
50
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
51 endfunction
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
52
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
53
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
54 %!assert (isstring ([]), false)
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
55 %!assert (isstring (1), false)
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
56 %!assert (isstring ('a'), false)
24634
ab2321d4ba03 maint: strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
57 ## FIXME: when string arrays are implemented, this should return true.
24474
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
58 #%!assert (isstring ("b"), true)
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
59 %!assert (isstring ({'a'}), false)
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
60 %!assert (isstring ({"b"}), false)
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
61
28886
d8318c12d903 test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents: 27923
diff changeset
62 %!error <Invalid call> isstring ()
24474
0b65949870e3 isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff changeset
63 %!error isstring ("a", "b")