Am 18.09.2015 um 19:26 schrieb Allin Cottrell:
On Tue, 15 Sep 2015, Sven Schreiber wrote:
> what ever happenend to this thread dangling in the air for a year now?:
> I like Logan's idea. I might also like jack's conversion function
> idea. Currently it seems we have a bit of a confusion over the how a
> set of names is stored or returned: in some functions it's
> comma-separated, in others it's space-separated, and then there are
> string arrays. IMHO this could use some consolidation.
> In any case I don't regard the introduction of a new function like
> "varnames" as evil. Just like in the matrix/matrices distinction, the
> plural-s indicates the array nicely I think.
Yes, it could use some consolidation. In the meantime (in CVS) I've
added a varnames() function as you suggest -- like varname() but returns
an array. I was holding off on this, hoping to come up with a "clever"
way of overloading the existing function, but it's probably cleaner just
to add a new one.
First of all, thanks.
Secondly, with respect to the consolidation, let me point out that the
strsplit() function almost does what's needed: it uses whitespace to
chop a string into several strings and returns them in an array.
If the second argument were generalized (currently it's an integer to
pick out one piece) to also allow a string, this string could define the
character(s) to use for chopping up the string, like this:
string in = "ahem,yep,omg"
strings out = strsplit(in, ",") # proposal
And 'out' would be a three-element array with "ahem", "yep",
And while I'm at it, perhaps a reverse function 'strjoin' could also be
useful that takes an array of strings and concatenates them (with an
optionally defined character), like this:
# use the string array 'out' from above
string joined = strjoin(out, ";")
And 'joined' would result as "ahem;yep;omg".
The new varnames() function could then be removed, I guess.