The following implements various basic forms of iteration and imaging of expressions, taking into account both plain operations and compounds. Some hints to remember the function names:
A
— Like the ∀ operator, the predicate holds for all subexpressions.E
— Like the ∃ operator, the predicate holds for at least one subexpression.img
— The image under the given functioniter
X — An iterative (sequential) variant of the algorithm X bare
X — A variant of X which takes a bare (context-free) function.k
— A variant of X which pass the operand number as the first argument.Functions ending with _view
take a first argument cuex_opview_t, which specifies how the operands are passed to the callback. In particular, operations and non-commutative containers can be given a commutative view. Each operand will then be replaced on the fly by cuex_o2_metapair(ei, eo)
where ei is a cudyn_int of the operand number and eo is the original operand. Callbacks to image functions are expected to return the result in the same format.
enum cuex_opview_t |
The compound view specifies how to iterate over or reconstruct operations and compounds.
True iff f takes every immediate subexpression of e to true. This is the same as cuex_iterA_operands, but with unordered invocation, and the additional requirement that f is safe for parallel invocation.
cu_bool_t cuex_A_operands_view | ( | cuex_opview_t | view, | |
cu_clop(f, cu_bool_t, cuex_t) | , | |||
cuex_t | e | |||
) |
Like cuex_A_operands but with a specified view of operands.
Like cuex_A_operands but also pass the operand number to f.
cu_bool_t cuex_Ak_operands_view | ( | cuex_opview_t | view, | |
cu_clop(f, cu_bool_t, int, cuex_t) | , | |||
cuex_t | e | |||
) |
Like cuex_A_operands but also pass the operand number to f and use the specified view of the operands.
A variant of cuex_A_operands specialised for context-free callbacks.
A variant of cuex_E_operand specialised for context-free callbacks.
A variant of cuex_img_operands specialised for context-free callbacks.
True iff f takes some immediate subexpression of e to true. This is the same as cuex_iterE_operand, but with unordered invocation, and the additional requirement that f is safe for parallel invocation.
Returns the result of replacing each immediate subexpression of e with its mapping under f. This is the same as cuex_iterimg_operands, but with unordered invocation, and the additional requirement that f is safe for parallel invocation.
cuex_t cuex_img_operands_view | ( | cuex_opview_t | view, | |
cu_clop(f, cuex_t, cuex_t) | , | |||
cuex_t | e | |||
) |
A variant of cuex_img_operands with a specified view of operands.
As cuex_img_operands but also pass the operand number as the first argument to f.
cuex_t cuex_imgk_operands_view | ( | cuex_opview_t | view, | |
cu_clop(f, cuex_t, int, cuex_t) | , | |||
cuex_t | e | |||
) |
A variant of cuex_imgk_operands with a specified view of operands.
Calls f on each immediate subexpression of e in operand order.
Calls f on each subexpression of e in operand order and builds the conjunction of the results, exiting as soon as f returns false.
cu_bool_t cuex_iterA_operands_view | ( | cuex_opview_t | view, | |
cu_clop(f, cu_bool_t, cuex_t) | , | |||
cuex_t | e | |||
) |
Like cuex_iterA_operands but using specified view of operands.
Like ref cuex_iterA_operands but also pass the operand number to f.
cu_bool_t cuex_iterAk_operands_view | ( | cuex_opview_t | view, | |
cu_clop(f, cu_bool_t, int, cuex_t) | , | |||
cuex_t | e | |||
) |
Like cuex_iterA_operands but also pass the operand number to f and use the specified view.
Calls f on each subexpression of e in operand order and builds the disjunction of the results, exiting as soon as f returns true.
Returns the result of replacing each immediate subexpression of e with its mapping under f, where f is called in operand order. If f returns NULL
, this function immediately returns NULL
, as well.
cuex_t cuex_iterimg_operands_view | ( | cuex_opview_t | view, | |
cu_clop(f, cuex_t, cuex_t) | , | |||
cuex_t | e | |||
) |
As cuex_iterimg_operands but using a specified of operands.
Like cuex_iterimg_operands but also pass the operand number as the first argument to f.
cuex_t cuex_iterimgk_operands_view | ( | cuex_opview_t | view, | |
cu_clop(f, cuex_t, int, cuex_t) | , | |||
cuex_t | e | |||
) |
As cuex_iterimgk_operands but using a specified of operands.