Mercurial > hg > octave-nkf
annotate scripts/strings/rindex.m @ 13164:36afcd6fc45f
Allow cellstr inputs to *2dec conversion functions (Bug #34147).
* base2dec.m, bin2dec.m, hex2dec.m: Allow cellstr inputs.
Amend documentation for new feature and add test for new behavior.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 19 Sep 2011 17:15:07 -0700 |
parents | fd0a3ac60b0e |
children | 1a6537dbce7b |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 1996-2011 Kurt Hornik |
2325 | 2 ## |
2313 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
2271 | 18 |
3361 | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} rindex (@var{s}, @var{t}) | |
6139 | 21 ## Return the position of the last occurrence of the character string |
22 ## @var{t} in the character string @var{s}, or 0 if no occurrence is | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
23 ## found. For example: |
3426 | 24 ## |
3361 | 25 ## @example |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
26 ## @group |
3361 | 27 ## rindex ("Teststring", "t") |
28 ## @result{} 6 | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
29 ## @end group |
3361 | 30 ## @end example |
3426 | 31 ## |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
32 ## @strong{Caution:} This function does not work for arrays of |
6139 | 33 ## character strings. |
34 ## @seealso{find, index} | |
3361 | 35 ## @end deftypefn |
2271 | 36 |
5428 | 37 ## Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> |
2355 | 38 ## Adapted-By: jwe |
2314 | 39 |
2311 | 40 function n = rindex (s, t) |
2271 | 41 |
2303 | 42 ## This is patterned after the AWK function of the same name. |
2271 | 43 |
44 if (nargin != 2) | |
6046 | 45 print_usage (); |
2271 | 46 endif |
47 | |
6139 | 48 n = index (s, t, "last"); |
3911 | 49 |
2271 | 50 endfunction |
7411 | 51 |
52 %!assert(rindex ("foobarbaz", "b") == 7 && rindex ("foobarbaz", "o") == 3); | |
53 | |
54 %!error rindex (); | |
55 | |
56 %!error rindex ("foo", "bar", 3); | |
57 |