<commit_before>'use strict';

(function(root, factory) {
    
    if (typeof exports === 'object' && exports) {
        factory(exports); // CommonJS
    } else {
        var sUTL = {};
        factory(sUTL);
        if (typeof define === 'function' && define.amd)
            define(sUTL); // AMD
        else
            root.sUTL = sUTL; // <script>
    }

}(this, function(sUTL) {
    
    //exports
    sUTL.name = 'sUTL.js';
    sUTL.version = '0.0.0';
    sUTL.transform = transform;

    function builtins()
    {
        return {
            "path": function(parentscope, scope, source, tt)
            {
                var fullpath = scope["path"]
                var unwrap = scope["unwrap"]

                var prefix = fullpath.slice(0, 1)
                var path = fullpath.slice(1)
                var childscope = null;

                if (prefix == '@')
                {
                    childscope = parentscope
                }
                if (prefix == '^')
                {
                    childscope = scope
                }
                else if (prefix == '$')
                {
                    childscope = source
                }
                else if (prefix == '~')
                {
                    childscope = tt
                }

                var retval = jsonPath(childscope, "$" + path)

                if (unwrap)
                {
                    if (retval.length > 0)
                        retval = retval[0]
                    else
                        retval = null
                }

                return retval
            },
            "cons": function(parentscope, scope, source, tt)
            {
                var head = scope["head"]
                var tail = scope["tail"]

                var retval = [head]

                if (tail)
                    retval = retval.concat(tail)

                return retval
            },
            "last": function(parentscope, scope, source, tt)
            {
                var lin = scope["in"]

                var retval = lin[lin.length-1]

                return retval
            },
            "add": function(parentscope, scope, source, tt)
            {
                var a = scope["a"]
                var b = scope["b"]

                return a + b
            },
            "if": function(parentscope, scope, source, tt)
            {
                var retval = null;
                var condvalue = false;

                if ("cond" in scope)
                    condvalue = Evaluate(parentscope, scope["cond"], source, tt)
                    if (isArray(condvalue) && condvalue.length == 0)
                        condvalue = false

                if (condvalue)
                {
                    if ("true" in scope)
                        retval = Evaluate(parentscope, scope["true"], source, tt)
                }
                else
                {
                    if ("false" in scope)<commit_msg>Added a bunch of builtins<commit_after>'use strict';

(function(root, factory) {
    
    if (typeof exports === 'object' && exports) {
        factory(exports); // CommonJS
    } else {
        var sUTL = {};
        factory(sUTL);
        if (typeof define === 'function' && define.amd)
            define(sUTL); // AMD
        else
            root.sUTL = sUTL; // <script>
    }

}(this, function(sUTL) {
    
    //exports
    sUTL.name = 'sUTL.js';
    sUTL.version = '0.0.0';
    sUTL.transform = transform;

    function get(scope, key, adefault)
    {
        if (key in scope)
            return scope[key]
        else
            return adefault
    }
    
    function builtins()
    {
        return {
            "path": function(parentscope, scope, source, tt)
            {
                var fullpath = scope["path"]
                var unwrap = scope["unwrap"]

                var prefix = fullpath.slice(0, 1)
                var path = fullpath.slice(1)
                var childscope = null;

                if (prefix == '@')
                {
                    childscope = parentscope
                }
                if (prefix == '^')
                {
                    childscope = scope
                }
                else if (prefix == '$')
                {
                    childscope = source
                }
                else if (prefix == '~')
                {
                    childscope = tt
                }

                var retval = jsonPath(childscope, "$" + path)

                if (unwrap)
                {
                    if (retval.length > 0)
                        retval = retval[0]
                    else
                        retval = null
                }

                return retval
            },
//             "cons": function(parentscope, scope, source, tt)
//             {
//                 var head = scope["head"]
//                 var tail = scope["tail"]

//                 var retval = [head]

//                 if (tail)
//                     retval = retval.concat(tail)

//                 return retval
//             },
//             "last": function(parentscope, scope, source, tt)
//             {
//                 var lin = scope["in"]

//                 var retval = lin[lin.length-1]

//                 return retval
//             },
            "+": function(parentscope, scope, source, tt)
            {
                return get(scope, "a", 0) + get(scope, "b", 0)
            },
            "-": function(parentscope, scope, source, tt)
            {
                return get(scope, "a", 0) - get(scope, "b", 0)
            },
            "*": function(parentscope, scope, source, tt)
            {
                return get(scope, "a", 1) * get(scope, "b", 1)
            },
            "/": function(parentscope, scope, source, tt)
            {
                return get(scope, "a", 1) / get(scope, "b", 1)
            },
            "if": function(parentscope, scope, source, tt)
            {
                var retval = null;
                var condvalue = false;

                if ("cond" in scope)
                    condvalue = Evaluate(parentscope, scope["cond"], source, tt)
                    if (isArray(condvalue) && condvalue.length == 0)
                        condvalue = false

                if (condvalue)
                {
                    if ("true" in scope)
                        retval = Evaluate(parentscope, scope["true"], source, tt)
                }
                else
                {
                    if ("false" in scope)
{'fraction_non_alphanumeric': 0.11213820275799363, 'fraction_numerical': 0.004243067131383543, 'mean_word_length': 0.9354838709677419, 'pattern_counts': {'":': 13, '<': 5, '<?xml version=': 0, '>': 7, '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': '7667566', 'n_tokens_mistral': 1748, 'n_tokens_neox': 1632, 'n_words': 410}