[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: |
Fri, 11 Mar 2005 19:53:15 +0100 |
> octave:1> string = "abc";
> octave:2> string(end)+=1
> string = abd
>
>It's not the same. In Perl, s="abz";s++ gives s="aca"; it really is magical :)
Here ia a first try at a function doing that. If people find it useful,
I'll write a full copyright notice.
This is copyright by me, now, under the GPL.
===File ~/math/octavelib/utils/strinc.m=====================
function rets = strinc(s)
nums = "0123456789";
lowl = "abcdefghijklmnopqrstuvz";
upls = "ABCDEFGHIJKLMNOPQRSTUVZ";
all = union(nums, union(lowl, upls));
if (length(s) == 0)
error("cannot increment: maximum reached");
endif
last = s(end);
if ((pos = index(nums, last)) > 0)
cset = nums;
elseif ((pos = index(lowl, last)) > 0)
cset = lowl;
elseif ((pos = index(upls, last)) > 0)
cset = upls;
else
error("cannot increment: successive of \"%s\" unknown", last);
endif
l = length(cset);
s(end) = cset(mod(pos+1,l));
if (pos == l)
rets = [strinc(s(1:end-1)), s(end)];
else
rets = s;
endif
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
-------------------------------------------------------------