Exemple #1
0
expr symbol_::subs(const exmap &m) const
{
  exmap::const_iterator it = m.find( this ), en = m.end();
  if( it != en )
    return it->second;
  return this;
}
Exemple #2
0
expr basic::subs_once(const exmap &map) const
{
  auto end = map.cend();
  auto it  = map.find( this );

  if( it != end )
    return it->second.subs( map );

  match_state s;

  for( it =  map.begin(); it != end; ++it )
    if( match( it->first, s ) )
    {
      exmap m;
      s.as_exmap( m );
      return it->second.subs( m );
    }

  return this->eval(2);
}
Exemple #3
0
/** Helper function for subs(). Does not recurse into subexpressions. */
ex basic::subs_one_level(const exmap & m, unsigned options) const
{
    exmap::const_iterator it;

    if (options & subs_options::no_pattern) {
        ex thisex = *this;
        it = m.find(thisex);
        if (it != m.end())
            return it->second;
        return thisex;
    } else {
        for (it = m.begin(); it != m.end(); ++it) {
            exmap repl_lst;
            if (match(ex_to<basic>(it->first), repl_lst))
                return it->second.subs(repl_lst, options | subs_options::no_pattern);
            // avoid infinite recursion when re-substituting the wildcards
        }
    }

    return *this;
}