|
From: Ethan M. <merritt@u.washington.edu> - 2009-02-02 17:13:26
|
On Saturday 31 January 2009 02:15:49 Petr Mikulik wrote:
> > I propose the patch below, which adds a function that returns the
> > string that defines a specified user defined function.
>
> 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"
> ?
>
> I though there are some "string" functions that could allow this, but it
> seems we don't have "string index" or "string split" functions.
We do. It is called strstrt(haystack,needle):
gnuplot> show var GPFUN
GPFUN_f = "f(a,b) = a**2 + sqrt(b*a)"
gnuplot> print strstrt(GPFUN_f,"=")
8
gnuplot> print GPFUN_f[ strstrt(GPFUN_f,"=") : * ]
= a**2 + sqrt(b*a)
gnuplot> print GPFUN_f[ strstrt(GPFUN_f,"=")+1 : * ]
a**2 + sqrt(b*a)
gnuplot> body = GPFUN_f[strstrt(GPFUN_f,"=")+1:*]
gnuplot> print body
a**2 + sqrt(b*a)
>
> 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"
>
> ---
> PM
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> gnuplot-beta mailing list
> gnu...@li...
> https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
>
--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742
|