Hi! On Sat, Apr 07, 2001 at 05:18:42PM +0200, Pearu Peterson wrote:
For example, by a special print_context object, say, print_callback, that contains an user-defined function
This doesn't sound different from a general tree-traversal function like this one: static void traverse(const ex & e) { cout << e.bp->class_name() << "("; unsigned n = e.nops(); if (n) for (unsigned i=0; i<n; i++) { traverse(e.op(i)); if (i != n-1) cout << ","; } else cout << "'" << e << "'"; cout << ")"; } "traverse(pow(2, n) + 3)" will produce add(power(numeric('2'),symbol('n')),numeric('3')) The traverse() function needs further refinement because some classes have additional properties that are not accessible via op() (the most noticable error is that all functions are printed as "function(...)" instead of with their real name; and there doesn't seem to be a way to get the name from a function object (this will be corrected shortly)), but basically it seems to be what you want. Bye, Christian -- / Coding on PowerPC and proud of it \/ http://www.uni-mainz.de/~bauec002/