eTree_t* eTreeCombine

(void* func, eTree_t* t1, eTree_t* t2)

Combine two trees with a specified operator.


Creates a tree with func operator at its root, t1 as left branch and t2 as right branch. If func is a binary operator (ie. a double func(double, double)), then both t1 and t2 MUST be trees (or single nodes). If func is an unary operator (of a form double func(double)), then t1 is its argument, while t2 MUST be NULL.

Both trees MUST share the same eVariable_t structure!

The newly created tree does NOT contain a copy of source trees, they become incorporated into it and t1 and/or t2 point to its branches. Value of each branch or the whole trees can be still independently computed. However, when the tree is to be removed, ONLY the new one should be passed to eTreeDestroy() - the tree will be deleted with its branch(es).

Pointer to the root of the new tree.
See Also:
eParse(), eTreeDestroy()

Alphabetic index

libsexpr - a simple library for parsing arithmetic expressions
© 2003 by Marcin Simonides