d69db172a1
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
27 lines
923 B
C++
27 lines
923 B
C++
/*
|
|
Copyright (c) 2013-2014 Microsoft Corporation. All rights reserved.
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Author: Leonardo de Moura
|
|
*/
|
|
#pragma once
|
|
#include <tuple>
|
|
#include "util/buffer.h"
|
|
#include "util/interrupt.h"
|
|
#include "kernel/expr.h"
|
|
#include "kernel/expr_maps.h"
|
|
|
|
namespace lean {
|
|
/**
|
|
\brief Apply <tt>f</tt> to the subexpressions of a given expression.
|
|
|
|
f is invoked for each subexpression \c s of the input expression e.
|
|
In a call <tt>f(s, n)</tt>, n is the scope level, i.e., the number of
|
|
bindings operators that enclosing \c s. The replaces only visits children of \c e
|
|
if f return none_expr.
|
|
*/
|
|
expr replace(expr const & e, std::function<optional<expr>(expr const &, unsigned)> const & f);
|
|
inline expr replace(expr const & e, std::function<optional<expr>(expr const &)> const & f) {
|
|
return replace(e, [&](expr const & e, unsigned) { return f(e); });
|
|
}
|
|
}
|