[GiNaC-devel] Best way to iterate through an expression

Jan Rheinländer jrheinlaender at gmx.de
Tue May 9 17:41:33 CEST 2017


Hi Vladimir,

yes, I know about the map() function. But that recurses into all
sub-expressions, doesn't it? I only want to work on the top-level
subexpressions. That is, if the expression is a mul, on its factors,
otherwise on the expression itself.

I suppose I could pass a level argument to the map function, but that
seems like a lot of overhead for a simple problem. Most of the time I
apply only a single line of code to my expression. Coding that in a
map() function would result in lots more lines of code plus an extra
function.

The sort of thing I am thinking of is that iteration over an expression
would work even if the expression consists e.g. of a single integral.

Greetings,
    Jan



More information about the GiNaC-devel mailing list