コード例 #1
0
ファイル: symbol.cpp プロジェクト: cjgillot/mycas
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;
}
コード例 #2
0
ファイル: subs.cpp プロジェクト: cjgillot/mycas
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);
}
コード例 #3
0
ファイル: basic.cpp プロジェクト: bachir151/feelpp
/** 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;
}