<commit_before>/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.

Author: <NAME>
*/
#pragma once
#include <memory>
#include <utility>
#include <functional>
#include "util/buffer.h"
#include "kernel/expr.h"
#include "kernel/expr_sets.h"

namespace lean {
/**
    \brief Expression visitor.

    The argument \c F must be a lambda (function object) containing the method

    <code>
    void operator()(expr const & e, unsigned offset)
    </code>

    The \c offset is the number of binders under which \c e occurs.
*/
class for_each_fn {
    std::unique_ptr<expr_cell_offset_set>       m_visited;
    std::function<bool(expr const &, unsigned)> m_f; // NOLINT
    void apply(expr const & e, unsigned offset);
public:
    template<typename F> for_each_fn(F && f):m_f(f) {}
    template<typename F> for_each_fn(F const & f):m_f(f) {}
    void operator()(expr const & e) { apply(e, 0); }
};

template<typename F> void for_each(expr const & e, F && f) {
    return for_each_fn(f)(e);
}
}
<commit_msg>fix(kernel/for_each_fn): typo<commit_after>/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.

Author: <NAME>
*/
#pragma once
#include <memory>
#include <utility>
#include <functional>
#include "util/buffer.h"
#include "kernel/expr.h"
#include "kernel/expr_sets.h"

namespace lean {
/**
    \brief Expression visitor.

    The argument \c F must be a lambda (function object) containing the method

    <code>
    bool operator()(expr const & e, unsigned offset)
    </code>

    The \c offset is the number of binders under which \c e occurs.
*/
class for_each_fn {
    std::unique_ptr<expr_cell_offset_set>       m_visited;
    std::function<bool(expr const &, unsigned)> m_f; // NOLINT
    void apply(expr const & e, unsigned offset);
public:
    template<typename F> for_each_fn(F && f):m_f(f) {}
    template<typename F> for_each_fn(F const & f):m_f(f) {}
    void operator()(expr const & e) { apply(e, 0); }
};

template<typename F> void for_each(expr const & e, F && f) {
    return for_each_fn(f)(e);
}
}

{'fraction_non_alphanumeric': 0.12959558823529413, 'fraction_numerical': 0.006433823529411764, 'mean_word_length': 3.8057395143487858, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '85770', 'n_tokens_mistral': 746, 'n_tokens_neox': 725, 'n_words': 233}