This document demonstrates how one can check if a variable has been previously defined in a gnuplot script.
The example from the doc:
a = 10
if (exists("a")) print "a is defined"
if (!exists("b")) print "b is not defined"
However, is it possible to check if a function has been previously defined?
In other words, is there a way to do the following:
f(x) = 2*x
if (exist("f(x)") print "Function is defined"
Thanks!
Every user-defined function is available as special variable with prefix GPFUN_
:
f(x) = 2*x
show variables GPFUN
prints
Variables beginning with GPFUN:
GPFUN_f = "f(x) = 2+x"
So you can check for the function with
f(x) = 2*x
if (exist("GPFUN_f") print "Function f is defined"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With