|
From: Petr M. <mi...@ph...> - 2009-02-01 23:05:06
|
> > > 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 :-).
Then it could be like
definition('f', 0)
=> a*x+y
definition('f', 1)
=> f(x)=a*x+y
> > 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
>
> 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"
Yes, by awk. I propose to start with 1 as it is currently used in
print word("a b c d e", 1)
=> "a"
print substr("hello", 1,99)
=> "hello"
I think it would be sufficient not to return separators
strsplit("hello, world, ahoj, svete", ",", 1) => "hello"
strsplit("hello, world, ahoj, svete", ",", 2) => "hello"
strsplit("hello, world, ahoj, svete", ",", 3) => "ahoj"
strsplit("hello, world, ahoj, svete", ",", 4) => "ahoj"
and this would also need
strsplitn("hello, world, ahoj, svete", ",") => 4
> To go along with strindex, I would also like to see:
> substr(string, index, length)
This exists, see above.
---
PM
|