<commit_before>//     autocell.js 0.0.1
//     https://github.com/buzzdecafe/autocell
//     (c) 2014 <NAME>
//     AutoCell may be freely distributed under the MIT license.
//
// AutoCell
// -----
// Tinkering with cellular automata.
//
// Basic Setup
// -----------
// Uses a technique from the [Universal Module Definition][umd] to wrap this up for use in Node.js or in the browser,
// with or without an AMD-style loader.
//
//  [umd]: https://github.com/umdjs/umd/blob/master/returnExports.js

(function (root, factory) {if (typeof exports === 'object') {module.exports = factory(root);} else if (typeof define === 'function' && define.amd) {define(factory);} else {root.autocell = factory(root);}}(this, function (global) {

    return  (function() {
     
      function trampoline(fn) {
        var result = fn.apply(this, [].slice.call(arguments, 1));
        while (typeof result === 'function') {
          result = result();
        }
        return result;
      }

      // draw the state to the screen
      function display(state) {
        // override me
        console.log(state); 
      }

      // simple 1D grid
      function applyRule(rule, state) {
        return state.map(function(cell, idx, arr) {
          var west = idx > 0 ? arr[idx - 1] : 0;
          var east = idx < state.length - 1 ? arr[idx + 1] : 0;
          return rule(west, cell, east);
        });
      }

      // `rule` is a map from state to state
      // `state` is the current state of the automaton
      // `steps` is the number of iterations to run
      function autocell(rule, state, steps) {
        var ac = function(r, s, t) {
          display(s);
          return (t <= 0) ? s : function() { setTimeout(function () { ac(r, applyRule(r, s), t - 1); }, 500); };
        };
        return trampoline(ac, rule, state, steps);
      }

      return autocell;

    }());
}));<commit_msg>simplify recursion w/o delay<commit_after>//     autocell.js 0.0.1
//     https://github.com/buzzdecafe/autocell
//     (c) 2014 <NAME>
//     AutoCell may be freely distributed under the MIT license.
//
// AutoCell
// -----
// Tinkering with cellular automata.
//
// Basic Setup
// -----------
// Uses a technique from the [Universal Module Definition][umd] to wrap this up for use in Node.js or in the browser,
// with or without an AMD-style loader.
//
//  [umd]: https://github.com/umdjs/umd/blob/master/returnExports.js

(function (root, factory) {if (typeof exports === 'object') {module.exports = factory(root);} else if (typeof define === 'function' && define.amd) {define(factory);} else {root.autocell = factory(root);}}(this, function (global) {

    return  (function() {
     
      function trampoline(fn) {
        var result = fn.apply(this, [].slice.call(arguments, 1));
        while (typeof result === 'function') {
          result = result();
        }
        return result;
      }

      // draw the state to the screen
      function display(state) {
        // override me
        console.log(state); 
      }

      // simple 1D grid
      function applyRule(rule, state) {
        return state.map(function(cell, idx, arr) {
          var west = idx > 0 ? arr[idx - 1] : 0;
          var east = idx < state.length - 1 ? arr[idx + 1] : 0;
          return rule(west, cell, east);
        });
      }

      // `rule` is a map from state to state
      // `state` is the current state of the automaton
      // `steps` is the number of iterations to run
      function autocell(rule, state, steps) {
        var ac = function(r, s, t) {
          display(s);
          return (t <= 0) ? s : function() { return ac(r, applyRule(r, s), t - 1); };
        };
        return trampoline(ac, rule, state, steps);
      }

      return autocell;

    }());
}));
{'fraction_non_alphanumeric': 0.15296924708377518, 'fraction_numerical': 0.009809119830328738, 'mean_word_length': 2.0699755899104963, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 4, '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': '1949127', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1134, 'n_words': 366}