annotate scripts/strings/isstrprop.m @ 33645:42355b7ec5d7 bytecode-interpreter tip

maint: Merge default to bytecode-interpreter.
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Tue, 04 Jun 2024 11:00:11 -0400
parents 2e484f9f1f18
children
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 ##
32632
2e484f9f1f18 maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 32495
diff changeset
3 ## Copyright (C) 2008-2024 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/>.
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 ##
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 ## This file is part of Octave.
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@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: 23220
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ##
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 ##
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@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: 23220
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 ########################################################################
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 ## -*- texinfo -*-
32001
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
27 ## @deftypefn {} {@var{tf} =} isstrprop (@var{str}, @var{prop})
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
28 ## @deftypefnx {} {@var{tf} =} isstrprop (@var{str}, @var{prop}, 'ForceCellOutput', @var{flag})
20164
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
29 ## Test character string properties.
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
30 ##
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
31 ## For example:
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 ##
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 ## @example
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 ## @group
8442
502e58a0d44f Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7530
diff changeset
35 ## isstrprop ("abc123", "alpha")
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 ## @result{} [1, 1, 1, 0, 0, 0]
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 ## @end group
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 ## @end example
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
39 ##
20164
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
40 ## If @var{str} is a cell array, @code{isstrpop} is applied recursively to
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
41 ## each element of the cell array.
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 ##
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 ## Numeric arrays are converted to character strings.
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 ##
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
45 ## The second argument @var{prop} must be one of
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 ##
11595
5ec6aa05638d Prevent doubled quotes around @table items in Info.
Rik <octave@nomad.inbox5.com>
parents: 11591
diff changeset
47 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17170
diff changeset
48 ## @item @qcode{"alpha"}
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
49 ## True for characters that are alphabetic (letters).
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 ##
25003
2365c2661b3c doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24534
diff changeset
51 ## @item @nospell{@qcode{"alnum"}}
2365c2661b3c doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24534
diff changeset
52 ## @itemx @nospell{@qcode{"alphanum"}}
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 ## True for characters that are alphabetic or digits.
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
54 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17170
diff changeset
55 ## @item @qcode{"lower"}
12642
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 11595
diff changeset
56 ## True for lowercase letters.
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
57 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17170
diff changeset
58 ## @item @qcode{"upper"}
12642
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 11595
diff changeset
59 ## True for uppercase letters.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
60 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17170
diff changeset
61 ## @item @qcode{"digit"}
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
62 ## True for decimal digits (0-9).
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
63 ##
25003
2365c2661b3c doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24534
diff changeset
64 ## @item @nospell{@qcode{"xdigit"}}
11591
1d13679b587e Use @nospell macro on certain words in docstrings.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
65 ## True for hexadecimal digits (@nospell{a-fA-F0-9}).
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
66 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17170
diff changeset
67 ## @item @qcode{"space"}
25003
2365c2661b3c doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24534
diff changeset
68 ## @itemx @nospell{@qcode{"wspace"}}
20164
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
69 ## True for whitespace characters (space, formfeed, newline, carriage return,
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
70 ## tab, vertical tab).
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
71 ##
25003
2365c2661b3c doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24534
diff changeset
72 ## @item @nospell{@qcode{"punct"}}
20164
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
73 ## True for punctuation characters (printing characters except space or
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
74 ## letter or digit).
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
75 ##
25003
2365c2661b3c doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24534
diff changeset
76 ## @item @nospell{@qcode{"cntrl"}}
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
77 ## True for control characters.
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
78 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17170
diff changeset
79 ## @item @qcode{"graph"}
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17170
diff changeset
80 ## @itemx @qcode{"graphic"}
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
81 ## True for printing characters except space.
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
82 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17170
diff changeset
83 ## @item @qcode{"print"}
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
84 ## True for printing characters including space.
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
85 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17170
diff changeset
86 ## @item @qcode{"ascii"}
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
87 ## True for characters that are in the range of ASCII encoding.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
88 ##
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 ## @end table
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 ##
32495
386d05bbae5a doc: Spellcheck documentation ahead of 9.1 release.
Rik <rik@octave.org>
parents: 32151
diff changeset
91 ## If the option @nospell{@qcode{'ForceCellOutput'}} is given and @var{flag} is
386d05bbae5a doc: Spellcheck documentation ahead of 9.1 release.
Rik <rik@octave.org>
parents: 32151
diff changeset
92 ## true then a cell value is returned rather than a logical array.
32001
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
93 ##
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
94 ## @seealso{isalpha, isalnum, islower, isupper, isdigit, isxdigit,
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
95 ## isspace, ispunct, iscntrl, isgraph, isprint, isascii}
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 ## @end deftypefn
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97
32001
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
98 function tf = isstrprop (str, prop, opt, flag)
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
99
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
100 if (nargin != 2 && nargin != 4)
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
101 print_usage ();
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
102 endif
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103
32001
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
104 force_cell_output = false;
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
105 if (nargin > 2)
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
106 if (! (isrow (opt) && strcmpi (opt, 'ForceCellOutput')))
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
107 error ("isstrprop: only accepted option is 'ForceCellOutput'");
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
108 elseif (! (isscalar (flag) && isreal (flag)))
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
109 error ("isstrprop: FLAG must be a real scalar");
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
110 endif
32151
72dcb1cef2c9 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 32001
diff changeset
111 force_cell_output = flag;
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 endif
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
114 switch (prop)
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
115 case "alpha"
30558
83aeaba707d8 doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents: 30330
diff changeset
116 tf = isalpha (str);
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
117 case {"alnum", "alphanum"}
30558
83aeaba707d8 doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents: 30330
diff changeset
118 tf = isalnum (str);
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
119 case "ascii"
30558
83aeaba707d8 doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents: 30330
diff changeset
120 tf = isascii (str);
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
121 case "cntrl"
30558
83aeaba707d8 doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents: 30330
diff changeset
122 tf = iscntrl (str);
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
123 case "digit"
30558
83aeaba707d8 doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents: 30330
diff changeset
124 tf = isdigit (str);
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
125 case {"graph", "graphic"}
30558
83aeaba707d8 doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents: 30330
diff changeset
126 tf = isgraph (str);
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
127 case "lower"
30558
83aeaba707d8 doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents: 30330
diff changeset
128 tf = islower (str);
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
129 case "print"
30558
83aeaba707d8 doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents: 30330
diff changeset
130 tf = isprint (str);
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
131 case "punct"
30558
83aeaba707d8 doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents: 30330
diff changeset
132 tf = ispunct (str);
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
133 case {"space", "wspace"}
30558
83aeaba707d8 doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents: 30330
diff changeset
134 tf = isspace (str);
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
135 case "upper"
30558
83aeaba707d8 doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents: 30330
diff changeset
136 tf = isupper (str);
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
137 case "xdigit"
30558
83aeaba707d8 doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory.
Rik <rik@octave.org>
parents: 30330
diff changeset
138 tf = isxdigit (str);
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
139 otherwise
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
140 error ("isstrprop: invalid string property");
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
141 endswitch
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
142
32001
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
143 if (force_cell_output)
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
144 tf = {tf};
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
145 endif
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
146
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147 endfunction
8442
502e58a0d44f Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7530
diff changeset
148
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
149
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
150 %!assert (isstrprop ("abc123", "alpha"), logical ([1, 1, 1, 0, 0, 0]))
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
151 %!assert (isstrprop ("abc123", "digit"), logical ([0, 0, 0, 1, 1, 1]))
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
152 %!assert (isstrprop ("Hello World", "wspace"), isspace ("Hello World"))
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
153 %!assert (isstrprop ("Hello World", "graphic"), isgraph ("Hello World"))
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
154 %!assert (isstrprop (char ("AbC", "123"), "upper"), logical ([1 0 1; 0 0 0]))
32001
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
155 %!assert (isstrprop (char ("AbC", "123"), "upper", 'ForceCellOutput', true),
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
156 %! {logical([1 0 1; 0 0 0])})
30330
01de0045b2e3 maint: Shorten some long lines to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29359
diff changeset
157 %!assert (isstrprop ({"AbC", "123"}, "lower"),
01de0045b2e3 maint: Shorten some long lines to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29359
diff changeset
158 %! {logical([0 1 0]), logical([0 0 0])})
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
159
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
160 ## Test input validation
28886
d8318c12d903 test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents: 27923
diff changeset
161 %!error <Invalid call> isstrprop ()
32001
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
162 %!error <Invalid call> isstrprop ("abc")
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
163 %!error <Invalid call> isstrprop ("abc", 'alpha', 'ForceCellOutput')
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
164 %!error <only accepted option is 'ForceCellOutput'>
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
165 %! isstrprop ('a', 'alpha', ['ForceCellOutput';'ForceCellOutput'], true)
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
166 %!error <only accepted option is 'ForceCellOutput'>
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
167 %! isstrprop ('a', 'alpha', 'Foobar', true)
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
168 %!error <FLAG must be a real scalar>
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
169 %! isstrprop ('a', 'alpha', 'ForceCellOutput', [true, true])
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
170 %!error <FLAG must be a real scalar>
51b503f5ca3a isstrprop.m: Add additional calling form with 'ForceCellOutput' for Matlab compatibility.
Rik <rik@octave.org>
parents: 31706
diff changeset
171 %! isstrprop ('a', 'alpha', 'ForceCellOutput', {true})
13312
e84d512b2438 isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
172 %!error <invalid string property> isstrprop ("abc123", "foo")