retrieving wildcard replacements on C++
Hi, suppose the following: symbol x("x"); ex foo = A*pow(x,2) + B*x; lst ocurrences; foo.find( wild(1)*x , ocurrences ); //the wildcard replacement is B how would you retrieve the wildcard replacement in this case? in ginsh you already get a list of the wildcards replacement, but after reading various times the relevant page of the tutorial, i couldn't find how is this done in c++ cheers __________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas
Dear Charlls, On Wed, 31 Jan 2007, Charlls Quarra wrote:
symbol x("x"); ex foo = A*pow(x,2) + B*x; lst ocurrences; foo.find( wild(1)*x , ocurrences ); //the wildcard replacement is B
how would you retrieve the wildcard replacement in this case?
In this simple case I would simply divide a list element by x ;-). In general it is a bit more difficult, but you could use cout << "list of wild(1)-replacements:" << endl; for (int i=0; i<ocurrences.nops(); ++i) { lst repls; ocurrences.op(i).match(wild(1)*x, repls); cout << wild(1).subs(repls, subs_options::no_pattern) << endl; } Best wishes, Chris
participants (2)
-
Charlls Quarra
-
Chris Dams