[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Loading multiple files
From: |
Francesco Potorti` |
Subject: |
Re: Loading multiple files |
Date: |
Sat, 12 Mar 2005 02:53:00 +0100 |
Ok, here is a simplified version, with error management and all that is
needed, I think. It remains to be seen if the behaviour is the same as
Perl's.
===File ~/math/octavelib/utils/strinc.m=====================
function incs = strinc(s)
## usage: incs = strinc (s)
##
## Given a string s, increment it similarly to the way Perl does.
##
## The last alphanumeric character is substituted by its successor, apart
## from the characters in "9zZ", which are substituted by those in "0aA",
## in which case the character to the left is also incremented, and so on.
##
## Francesco Potortì <address@hidden>, 2005 License: GNU GPL
## <http://www.gnu.org/licenses/gpl.html>
chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
newch = "1234567890bcdefghijklmnopqrstuvwxyzaBCDEFGHIJKLMNOPQRSTUVWXYZA";
if (length(s) == 0)
warning("wrapping around");
else
last = s(end);
pos = index(chars, last);
if (pos == 0)
error("cannot increment: successor of '%s' unknown", last);
endif
s(end) = newch(pos);
if (index("9zZ", last) > 0)
incs = [strinc(s(1:end-1)), s(end)];
return;
endif
endif
incs = s;
endfunction
============================================================
--
Francesco Potortì (ricercatore) Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR Fax: +39 050 313 8091
via G. Moruzzi 1, I-56124 Pisa Email: address@hidden
Web: http://fly.isti.cnr.it/ Key: fly.isti.cnr.it/public.key
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------