- ${STLT} s;
- RESERVE(s,seq.size());
-
- if (level==1) {
- return seq;
- }
- if (level == -max_recursion_level) {
- throw(std::runtime_error("max recursion level reached"));
- }
- --level;
- for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
- s.push_back((*it).eval(level));
- }
- return s;
-}
-
-${STLT} ${CONTAINER}::evalfchildren(int level) const
-{
- ${STLT} s;
- RESERVE(s,seq.size());
-
- if (level==1) {
- return seq;
- }
- if (level == -max_recursion_level) {
- throw(std::runtime_error("max recursion level reached"));
- }
- --level;
- for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
- s.push_back((*it).evalf(level));
- }
- return s;
-}
-
-${STLT} ${CONTAINER}::normalchildren(int level) const
-{
- ${STLT} s;
- RESERVE(s,seq.size());
-
- if (level==1) {
- return seq;
- }
- if (level == -max_recursion_level) {
- throw(std::runtime_error("max recursion level reached"));
- }
- --level;
- for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
- s.push_back((*it).normal(level));
- }
- return s;
-}
-
-${STLT} ${CONTAINER}::diffchildren(const symbol & y) const
-{
- ${STLT} s;
- RESERVE(s,seq.size());
- for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
- s.push_back((*it).diff(y));
- }
- return s;
-}
-
-/* obsolete subschildren
-${STLT} ${CONTAINER}::subschildren(const lst & ls, const lst & lr) const
-{
- ${STLT} s;
- RESERVE(s,seq.size());
- for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
- s.push_back((*it).subs(ls,lr));
- }
- return s;
-}
-*/
-
-${STLT} * ${CONTAINER}::subschildren(const lst & ls, const lst & lr) const
-{
- // returns a NULL pointer if nothing had to be substituted
- // returns a pointer to a newly created epvector otherwise
- // (which has to be deleted somewhere else)
-
- ${STLT}::const_iterator last=seq.end();
- ${STLT}::const_iterator cit=seq.begin();
- while (cit!=last) {
- const ex & subsed_ex=(*cit).subs(ls,lr);
- if (!are_ex_trivially_equal(*cit,subsed_ex)) {
-
- // something changed, copy seq, subs and return it
- ${STLT} *s=new ${STLT};
- RESERVE(*s,seq.size());
-
- // copy parts of seq which are known not to have changed
- ${STLT}::const_iterator cit2=seq.begin();
- while (cit2!=cit) {
- s->push_back(*cit2);
- ++cit2;
- }
- // copy first changed element
- s->push_back(subsed_ex);
- ++cit2;
- // copy rest
- while (cit2!=last) {
- s->push_back((*cit2).subs(ls,lr));
- ++cit2;
- }
- return s;
- }
- ++cit;
- }
-
- return 0; // nothing has changed
+ ${STLT} s;
+ RESERVE(s,seq.size());
+
+ if (level==1) {
+ return seq;
+ }
+ if (level == -max_recursion_level) {
+ throw(std::runtime_error("max recursion level reached"));
+ }
+ --level;
+ ${STLT}::const_iterator it = seq.begin(), itend = seq.end();
+ while (it != itend) {
+ s.push_back(it->eval(level));
+ ++it;
+ }
+ return s;
+}
+
+${STLT} * ${CONTAINER}::subschildren(const lst & ls, const lst & lr, bool no_pattern) const
+{
+ // returns a NULL pointer if nothing had to be substituted
+ // returns a pointer to a newly created epvector otherwise
+ // (which has to be deleted somewhere else)
+
+ ${STLT}::const_iterator cit = seq.begin(), end = seq.end();
+ while (cit != end) {
+ const ex & subsed_ex = cit->subs(ls, lr, no_pattern);
+ if (!are_ex_trivially_equal(*cit, subsed_ex)) {
+
+ // something changed, copy seq, subs and return it
+ ${STLT} *s=new ${STLT};
+ RESERVE(*s, seq.size());
+
+ // copy parts of seq which are known not to have changed
+ ${STLT}::const_iterator cit2 = seq.begin();
+ while (cit2 != cit) {
+ s->push_back(*cit2);
+ ++cit2;
+ }
+
+ // copy first changed element
+ s->push_back(subsed_ex);
+ ++cit2;
+
+ // copy rest
+ while (cit2 != end) {
+ s->push_back(cit2->subs(ls, lr, no_pattern));
+ ++cit2;
+ }
+ return s;
+ }
+ ++cit;
+ }
+
+ return 0; // nothing has changed