<commit_before>//- JavaScript source code

//- demo.js ~~
//
//  I write this short demonstration in lieu of actual documentation :-P
//
//                                                      ~~ (c) SRW, 11 Oct 2011

(function () {
    'use strict';

    var x, y, z;

    x = [1, 2, 3, 4, 5];

    y = x.Q(function (x) {
        return x.map(function (each) {
            return 3 * each;
        });
    });

    y.onready = function (y, exit) {
        console.log(y);                 //> [3, 6, 9, 12, 15]
        exit.success(y);
    };

    z = y.Q(function (x) {
        return x.reduce(function (a, b) {
            return a + b;
        });
    });

    z.onready = function (z, exit) {
        console.log(z);                 //> 45
        exit.success(z);
    };

}());

//- vim:set syntax=javascript:<commit_msg>The "demo.js" now sports a monad-style chaining example.<commit_after>//- JavaScript source code

//- demo.js ~~
//
//  I write this short demonstration in lieu of actual documentation :-P
//
//                                                      ~~ (c) SRW, 11 Oct 2011

(function () {
    'use strict';

    var x, y, z;

    x = [1, 2, 3, 4, 5];

    y = x.Q(function (x) {
        return x.map(function (each) {
            return 3 * each;
        });
    });

    y.onready = function (y, exit) {
        console.log(y);                 //> [3, 6, 9, 12, 15]
        exit.success(y);
    };

    z = y.Q(function (x) {
        return x.reduce(function (a, b) {
            return a + b;
        });
    });

    z.onready = function (z, exit) {
        console.log(z);                 //> 45
        exit.success(z);
    };

}());

(function () {
    'use strict';

 // Here is the "same" program as above, implemented with a monadic style :-)

    [1, 2, 3, 4, 5].
        Q(function (x) {
            return x.map(function (each) {
                return 3 * each;
            });
        }).
        Q(function (x) {
            return x.reduce(function (a, b) {
                return a + b;
            });
        }).
        onready = function (x, exit) {
            console.log(x);
            exit.success(x);
        };

}());

//- vim:set syntax=javascript:
{'fraction_non_alphanumeric': 0.16348773841961853, 'fraction_numerical': 0.021798365122615803, 'mean_word_length': 1.254861821903787, 'pattern_counts': {'":': 0, '<': 3, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3288262', 'n_tokens_mistral': 762, 'n_tokens_neox': 700, 'n_words': 195}