[GiNaC-list] var list

Ralf Stephan ralf at ark.in-berlin.de
Tue Oct 5 12:21:03 CEST 2004

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
  lst symbols;
  CollectSymbols_Visitor() {}
  void visit (const symbol& x)
		for (lst::const_iterator i = symbols.begin(); i != symbols.end(); i++)
			if (*i == x)

int main()
  symbol x("x");

  ex e = x - 2;
	CollectSymbols_Visitor collector;
	e.accept (collector);
	const lst& sym = collector.symbols;

	cout << sym << endl;


More information about the GiNaC-list mailing list