A block that represents a local function whose value can be found and used as a term in a UserFunc expression (or in an <Expression>).
<Term>s are similar to Local UserFuncs;
the difference is that
<Term>s must take exactly the same arguments as
the containing function, and they are treated like an <Input> in the
containing function (although they shouldn’t appear in the inputOrder
,
and they are not arguments of the function).
Differences between Terms and local functions:
<Term f>
and a local
<UserFunc g>
appear in expression = if(a, f, g())
.
The expression f
is needed only if a
evaluates to true,
and g()
must be evaluated only if a
is false.
In this case f
will be evaluated regardless, while g()
is
evaluated only if a
is false. Therefore, using a local function
instead of a variable can sometimes save time.f
is a Term, and g()
a local function, each of which returns a random number, then in
expression = if(f < 0.5, f, 0.5) + if(g() < 0.5, g(), 0.5)
the same value will be used for both appearances of f
, but
each appearance of g()
will evaluate to a different number.Terms take all the same kinds (and corresponding attributes) as UserFuncs (see UserFunc Block).
This example can be contrasted with that using local functions (see Local UserFuncs).
<UserFunc f>
kind = expression
inputOrder = [ y ]
<Input y>
kind = arbitraryVector
types = [float]
</Input>
<Term mySqrVar>
kind = expression
inputOrder = [ y ] # same args as UserFunc f
<Input y>
kind = arbitraryVector
types = [float]
</Input>
expression = y*y
</Term>
<Term myPlusOneSqrVar>
kind = expression
inputOrder = [ y ] # same args as UserFunc f
<Input y>
kind = arbitraryVector
types = [float]
</Input>
expression = (y+1)*(y+1)
</Term>
expression = mySqrVar*myPlusOneSqrVar + y
</UserFunc>
In the above example, each Term is like a UserFunc that takes the
same arguments as function f
(namely, a scalar float named y
). The
Terms are then used in f’s expression as variables.
All Terms are evaluated before f’s expression is evaluated; this differs from local functions, which are typically evaluated only as needed.