The pre-defined functions conditionalN() and conditionalS() provide a compact means of inserting conditional expressions into numerical and string expressions respectively. Each takes three arguments, the first of which is a truth criterion to be tested. If the criterion is true, then the function’s second argument is returned as its output. Otherwise, the function’s third argument is returned. This is similar to the behaviour of C’s ternary ?: operator. The conditionalN() function should be passed two numerical expressions to select between, whilst the conditionalS() function should be passed two string expressions, as the following examples demonstrate:
pyxplot> f(x) = conditionalN(x0,x,0)
pyxplot> print "%s %s %s %s %s"%(f(-2),f(-1),f(0),f(1),f(2))
0 0 0 1 2
pyxplot> x = 2
pyxplot> print "x is %s"%(conditionalS(x0,"positive","negative"))
x is positive