|
From: James R. V. Z. <jr...@co...> - 2009-01-31 22:13:11
|
Petr Mikulik <mi...@ph...> writes:
> MIME-Version: 1.0
> Cc: gnu...@li...
> Content-Type: text/plain; charset="us-ascii"
>
> > I propose the patch below, which adds a function that returns the
> > string that defines a specified user defined function.
I have committed the code that Ethan Merritt posted. I may commit my
original implementation of definition() as well, if only because I can
touch type that faster (no upper case :-).
> I see it gives the following:
> GPFUN_f = "f(x,y)=x+y+20"
> GPFUN_g = "g(x,y)=x*y"
>
> I wonder how I can get the definition part only, i.e. "x+y+20" or "x*y".
>
> Maybe you could add another variable
> GPFUN__f = "x+y+20"
Not very mnemonic.
> I thought there are some "string" functions that could allow this,
> but it seems we don't have "string index" or "string split"
> functions. Maybe it would be also useful to have
> strindex("hello world", "llo") => 3
> strsplit("hello=world", "=", 0) => "hello"
> strsplit("hello=world", "=", 1) => "="
> strsplit("hello=world", "=", 2) => "world"
I agree. Yours are inspired by awk, I think. We could argue whether
indexes should start with 0 instead of 1. I suggest the second
argument of strsplit should be like the second argument of strspn in
C: tokens are separated by one or more characters from that string,
and the separators found are returned. E.g.
strsplit("hello, world", " ;," , 1) => ", "
strsplit("hello, world", " ;," , 2) => "world"
strsplit("hello, world", "," , 1) => ","
strsplit("hello, world", "," , 2) => " world"
To go along with strindex, I would also like to see:
substr(string, index, length)
- Jim Van Zandt
|