Mercurial > octave
annotate scripts/strings/isstring.m @ 28886:d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Remove BIST tests now that interpreter enforces calling function with no more than
the number of arguments defined in the function prototype.
* makeUniqueStrings.m, makeValidName.m, base64decode.m, base64encode.m,
record.m, sound.m, soundsc.m, acosd.m, acot.m, acotd.m, acoth.m, acsc.m,
acscd.m, acsch.m, asec.m, asecd.m, asech.m, asind.m, atan2d.m, atand.m, cosd.m,
cot.m, cotd.m, coth.m, csc.m, cscd.m, csch.m, sec.m, secd.m, sech.m, sind.m,
tand.m, accumdim.m, bincoeff.m, bitget.m, bitset.m, cell2mat.m, circshift.m,
cplxpair.m, cumtrapz.m, deg2rad.m, flip.m, fliplr.m, flipud.m, int2str.m,
interpft.m, logspace.m, num2str.m, postpad.m, prepad.m, rad2deg.m, rot90.m,
rotdim.m, shift.m, subsindex.m, trapz.m, rotx.m, roty.m, rotz.m, getappdata.m,
getpixelposition.m, guidata.m, isappdata.m, waitforbuttonpress.m,
__gripe_missing_component__.m, bessel.m, hsv2rgb.m, ind2gray.m, rgb2gray.m,
rgb2hsv.m, rgbplot.m, fileread.m, javachk.m, usejava.m, findstr.m,
genvarname.m, isdir.m, vectorize.m, cond.m, cross.m, duplication_matrix.m,
expm.m, isbanded.m, isdefinite.m, isdiag.m, ishermitian.m, issymmetric.m,
istril.m, istriu.m, trace.m, vech.m, vecnorm.m, cast.m, citation.m,
compare_versions.m, grabcode.m, inputname.m, isfile.m, isfolder.m, ismac.m,
ispc.m, isunix.m, list_primes.m, methods.m, news.m, open.m, run.m, swapbytes.m,
tar.m, verLessThan.m, zip.m, odeget.m, optimget.m, stemleaf.m, allchild.m,
ancestor.m, close.m, groot.m, hgsave.m, isaxes.m, isfigure.m, isgraphics.m,
ishandle.m, isprop.m, linkaxes.m, rotate.m, saveas.m, conv.m, poly.m,
polyint.m, polyreduce.m, ppval.m, roots.m, addpref.m, getpref.m, ispref.m,
rmpref.m, setpref.m, profile.m, profshow.m, powerset.m, autoreg_matrix.m,
bartlett.m, blackman.m, detrend.m, fftconv.m, fftfilt.m, fftshift.m, hamming.m,
hanning.m, ifftshift.m, sinewave.m, spectral_adf.m, spectral_xdf.m, unwrap.m,
nonzeros.m, spconvert.m, sprand.m, sprandn.m, beta.m, betainc.m, betaln.m,
cosint.m, expint.m, factorial.m, legendre.m, nchoosek.m, nthroot.m, perms.m,
pow2.m, primes.m, reallog.m, realpow.m, realsqrt.m, sinint.m, hankel.m, hilb.m,
invhilb.m, magic.m, pascal.m, toeplitz.m, vander.m, wilkinson.m, center.m,
corr.m, cov.m, discrete_cdf.m, discrete_inv.m, discrete_pdf.m, empirical_cdf.m,
empirical_inv.m, empirical_pdf.m, iqr.m, kendall.m, kurtosis.m, mad.m,
meansq.m, median.m, moment.m, prctile.m, quantile.m, range.m, run_count.m,
skewness.m, spearman.m, statistics.m, std.m, var.m, base2dec.m, bin2dec.m,
blanks.m, dec2base.m, dec2bin.m, dec2hex.m, endsWith.m, erase.m, hex2dec.m,
index.m, isletter.m, isstring.m, isstrprop.m, mat2str.m, ostrsplit.m, rindex.m,
startsWith.m, strtrunc.m, substr.m, fail.m, addtodate.m, asctime.m, ctime.m,
date.m, datestr.m, eomday.m, etime.m, is_leap_year.m, now.m:
remove unnecessary BIST tests in m-files checking for excessive number of inputs.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 09 Oct 2020 13:28:53 -0700 |
parents | bd51beb6205e |
children | de5f2f9a64ff |
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 ## |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 ## Copyright (C) 2017-2020 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 |
0b65949870e3
isstring.m: Add new function for identifying string arrays.
Rik <rik@octave.org>
parents:
diff
changeset
|
45 if (nargin != 1) |
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") |