5 Oct
2004
5 Oct
'04
2:21 p.m.
This must be a faq: Is there a function that returns a lst of all variables in an ex? Or, what's wrong with the following (which leaves symbols empty)? class CollectSymbols_Visitor : public visitor, public symbol::visitor { public: lst symbols; CollectSymbols_Visitor() {} void visit (const symbol& x) { for (lst::const_iterator i = symbols.begin(); i != symbols.end(); i++) if (*i == x) return; symbols.append(x); } }; int main() { symbol x("x"); ex e = x - 2; CollectSymbols_Visitor collector; e.accept (collector); const lst& sym = collector.symbols; cout << sym << endl; }