Mercurial > octave
annotate scripts/strings/isstring.m @ 31254:5d6b058a22dc
maint: use sequence "%!#" to disable BIST tests.
* interp1.m, logspace.m, triplequad.m, textread.m, __w2mpth__.m, ode15i.m,
__print_parse_opts__.m, ichol.m, discrete_rnd.m, isstring.m:
Use sequence "%!#" to disable BIST tests.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 04 Oct 2022 07:34:47 -0700 |
parents | 83f9f8bda883 |
children | caf42f5c3f4e 597f3ee61a48 |
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 -*- |
30558
83aeaba707d8
doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
27 ## @deftypefn {} {@var{tf} =} isstring (@var{s}) |
25039
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 |
30558
83aeaba707d8
doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
43 function tf = isstring (s) |
24474
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 |
30558
83aeaba707d8
doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
49 tf = false; |
24474
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. |
31254
5d6b058a22dc
maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
58 %!#assert (isstring ("b"), true) |
24474
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") |