<commit_before>#ifndef PYTHONIC_INTRINSICS_H
#define PYTHONIC_INTRINSICS_H

#include <tuple>
#include <sstream>
#include <complex>

namespace pythonic {

    /* abs */
    using std::abs;
    PROXY(pythonic, abs);

    /* all */
    template <class Iterable>
        bool all( Iterable && s) {
            //return s.end() == std::find_if(s.begin(), s.end(), [](typename Iterable::iterator::value_type const&t) { return not bool(t); });
			auto iend = s.end();
			for(auto iter = s.begin() ; iter != iend ; ++iter)
				if( not *iter ) return false;
			return true;
        }
    PROXY(pythonic, all);

    /* any */
    template <class Iterable>
        bool any( Iterable && s) {
			auto iend = s.end();
			for(auto iter = s.begin() ; iter != iend ; ++iter)
				if( *iter ) return true;
			return false;
        }
    PROXY(pythonic, any);

    /* bin */
    template<class T>
        core::string bin(T const &v) {
            long long unsigned int i = 1LL << (8*sizeof(T)-1);
            while(i and not (v&i)) i>>=1;
            if(not i) return "0b0";
            else {
                std::ostringstream oss;
                oss << "0b";
                for(; i ; i>>=1)
                    if(v & i) oss << "1";
                    else oss << "0";
                return oss.str();
            }
        }
    PROXY(pythonic, bin);

    /* chr */
    template<class T>
        core::string chr(T const &v) { return core::string(1,(char)v); }
    PROXY(pythonic, chr);

    /* cmp */
    template<class T0, class T1>
        long cmp(T0 const& v0, T1 const& v1) {
            return v0 == v1 ? 0 : ( v0 < v1 ? -1 : 1 );
        }
    PROXY(pythonic, cmp);

    /* complex */
    template<class T0, class T1=double> // do not handle string as first argument
    std::complex<double> complex(T0 const& v0, T1 const& v1 = 0.) {
        return std::complex<double>(v0,v1);
    }
    PROXY(pythonic, complex);

    /* dict */
    core::empty_dict dict() {
        return core::empty_dict();
    }
    PROXY(pythonic,dict);

    /* divmod */
    template<class T0, class T1>
        auto divmod(T0 const& t0, T1 const& t1) // other types are left over
            -> decltype(std::make_tuple(t0/t1, t0%t1)) {
                return std::make_tuple(t0/t1, t0%t1);
            }
    PROXY(pythonic, divmod);

    /* enumerate */
    template<class T>
    struct enumerate_iterator : std::iterator< std::random_access_iterator_tag, std::tuple<long, T> >{
        long value;
        typename core::list<T>::const_iterator iter;<commit_msg>Add dictionary initializer from list of pair.<commit_after>#ifndef PYTHONIC_INTRINSICS_H
#define PYTHONIC_INTRINSICS_H

#include <tuple>
#include <sstream>
#include <complex>

namespace pythonic {

    /* abs */
    using std::abs;
    PROXY(pythonic, abs);

    /* all */
    template <class Iterable>
        bool all( Iterable && s) {
            //return s.end() == std::find_if(s.begin(), s.end(), [](typename Iterable::iterator::value_type const&t) { return not bool(t); });
			auto iend = s.end();
			for(auto iter = s.begin() ; iter != iend ; ++iter)
				if( not *iter ) return false;
			return true;
        }
    PROXY(pythonic, all);

    /* any */
    template <class Iterable>
        bool any( Iterable && s) {
			auto iend = s.end();
			for(auto iter = s.begin() ; iter != iend ; ++iter)
				if( *iter ) return true;
			return false;
        }
    PROXY(pythonic, any);

    /* bin */
    template<class T>
        core::string bin(T const &v) {
            long long unsigned int i = 1LL << (8*sizeof(T)-1);
            while(i and not (v&i)) i>>=1;
            if(not i) return "0b0";
            else {
                std::ostringstream oss;
                oss << "0b";
                for(; i ; i>>=1)
                    if(v & i) oss << "1";
                    else oss << "0";
                return oss.str();
            }
        }
    PROXY(pythonic, bin);

    /* chr */
    template<class T>
        core::string chr(T const &v) { return core::string(1,(char)v); }
    PROXY(pythonic, chr);

    /* cmp */
    template<class T0, class T1>
        long cmp(T0 const& v0, T1 const& v1) {
            return v0 == v1 ? 0 : ( v0 < v1 ? -1 : 1 );
        }
    PROXY(pythonic, cmp);

    /* complex */
    template<class T0, class T1=double> // do not handle string as first argument
    std::complex<double> complex(T0 const& v0, T1 const& v1 = 0.) {
        return std::complex<double>(v0,v1);
    }
    PROXY(pythonic, complex);

    /* dict */
    core::empty_dict dict() {
        return core::empty_dict();
    }

	template<class Iterable>
		core::dict<typename std::tuple_element<0, typename std::remove_reference<Iterable>::type::iterator::value_type>::type ,
				   typename std::tuple_element<1, typename std::remove_reference<Iterable>::type::iterator::value_type>::type >
					   dict( Iterable&& iterable) {
						   core::dict<typename std::tuple_element<0, typename std::remove_reference<Iterable>::type::iterator::value_type>::type ,
						   typename std::tuple_element<1, typename std::remove_reference<Iterable>::type::iterator::value_type>::type > out=core::empty_dict();
						   for(auto const & i : iterable)
							   out[std::get<0>(i)] = std::get<1>(i);
						   return out;
					   }
    PROXY(pythonic,dict);

    /* divmod */
    template<class T0, class T1>
        auto divmod(T0 const& t0, T1 const& t1) // other types are left over
            -> decltype(std::make_tuple(t0/t1, t0%t1)) {
                return std::make_tuple(t0/t1, t0%t1);
            }
    PROXY(pythonic, divmod);

    /* enumerate */
    template<class T>
    struct enumerate_iterator : std::iterator< std::random_access_iterator_tag, std::tuple<long, T> >{
        long value;
        typename core::list<T>::const_iterator iter;
{'fraction_non_alphanumeric': 0.15270596346087556, 'fraction_numerical': 0.01723543605653223, 'mean_word_length': 2.1990077177508267, 'pattern_counts': {'":': 0, '<': 66, '<?xml version=': 0, '>': 58, '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': '5920002', 'n_tokens_mistral': 2067, 'n_tokens_neox': 1952, 'n_words': 477}