<commit_before>/* vim:set ts=2 sw=2 sts=2 expandtab */
/*jshint asi: true undef: true es5: true node: true browser: true devel: true
         forin: true latedef: false globalstrict: true */
'use strict';

var List = require('./list').List

var sequence = require('./sequence'),
    count = sequence.count,
    first = sequence.first, rest = sequence.rest, cons = cons,
    isEmpty = sequence.isEmpty, empty = sequence.empty

function Binoid(left, right) {
  this.left = left || null
  this.right = right || null
}
Binoid.prototype.toString = function toString() {
  var value = '', tail = this.left;
  while (!isEmpty(tail)) {
    value = value + ' ' + first(tail)
    tail = rest(tail)
  }
  tail = this.right
  while (!isEmpty(tail)) {
    value = value + ' ' + first(tail)
    tail = rest(tail)
  }

  return '(' + value.substr(1) + ')'
 
}

first.define(Binoid, function(self) {
  return self.left ? first(self.left) :
         self.right ? first(self.right) :
         null
})

rest.define(Binoid, function(self) {
  var tail = rest(self.left)
  return isEmpty(tail) ? self.right :
                         new Binoid(tail, self.right)
})

count.define(Binoid, function(self) {
  return count(self.left) + count(self.right)
})

exports.concat = function concat(left, right) {
  return new Binoid(left, right)
}<commit_msg>export concat function from binoid module. <commit_after>/* vim:set ts=2 sw=2 sts=2 expandtab */
/*jshint asi: true undef: true es5: true node: true browser: true devel: true
         forin: true latedef: false globalstrict: true */
'use strict';

var List = require('./list').List

var sequence = require('./sequence'),
    count = sequence.count,
    first = sequence.first, rest = sequence.rest, cons = cons,
    isEmpty = sequence.isEmpty, empty = sequence.empty

function Binoid(left, right) {
  this.left = left || null
  this.right = right || null
}
Binoid.prototype.toString = function toString() {
  var value = '', tail = this.left;
  while (!isEmpty(tail)) {
    value = value + ' ' + first(tail)
    tail = rest(tail)
  }
  tail = this.right
  while (!isEmpty(tail)) {
    value = value + ' ' + first(tail)
    tail = rest(tail)
  }

  return '(' + value.substr(1) + ')'
}

first.define(Binoid, function(self) {
  return self.left ? first(self.left) :
         self.right ? first(self.right) :
         null
})

rest.define(Binoid, function(self) {
  var tail = rest(self.left)
  return isEmpty(tail) ? self.right :
                         new Binoid(tail, self.right)
})

count.define(Binoid, function(self) {
  return count(self.left) + count(self.right)
})

function concat(left, right) {
  return new Binoid(left, right)
}
exports.concat = concat
{'fraction_non_alphanumeric': 0.14827201783723523, 'fraction_numerical': 0.0037160906726124115, 'mean_word_length': 3.1351766513056836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2907352', 'n_tokens_mistral': 890, 'n_tokens_neox': 881, 'n_words': 229}