<commit_before>'use strict';

exports.symbols = {
  // GREEK LETTERS
  Alpha: 'A',     alpha: '\\alpha',
  Beta: 'B',      beta: '\\beta',
  Gamma: '\\Gamma',    gamma: '\\gamma',
  Delta: '\\Delta',    delta: '\\delta',
  Epsilon: 'E',   epsilon: '\\epsilon',  varepsilon: '\\varepsilon',
  Zeta: 'Z',      zeta: '\\zeta',
  Eta: 'H',       eta: '\\eta',
  Theta: '\\Theta',    theta: '\\theta',    vartheta: '\\vartheta',
  Iota: 'I',      iota: '\\iota',
  Kappa: 'K',     kappa: '\\kappa',    varkappa: '\\varkappa',
  Lambda: '\\Lambda',   lambda: '\\lambda',
  Mu: 'M',        mu: '\\mu',
  Nu: 'N',        nu: '\\nu',
  Xi: '\\Xi',       xi: '\\xi',
  Omicron: 'O',   omicron: 'o',
  Pi: '\\Pi',       pi: '\\pi',       varpi: '\\varpi',
  Rho: 'P',       rho: '\\rho',      varrho: '\\varrho',
  Sigma: '\\Sigma',    sigma: '\\sigma',    varsigma: '\\varsigma',
  Tau: 'T',       tau: '\\tau',
  Upsilon: '\\Upsilon',  upsilon: '\\upsilon',
  Phi: '\\Phi',      phi: '\\phi',      varphi: '\\varphi',
  Chi: 'X',       chi: '\\chi',
  Psi: '\\Psi',      psi: '\\psi',
  Omega: '\\Omega',    omega: '\\omega',
  //logic
  'true': '\\mathrm{True}',
  'false': '\\mathrm{False}',
  //other
  i: 'i', //TODO use \i ??
  inf: '\\infty',
  Inf: '\\infty',
  infinity: '\\infty',
  Infinity: '\\infty',
  oo: '\\infty',
  lim: '\\lim',
  'undefined': '\\mathbf{?}'
};

//create a comma separated list of function arguments
function functionArgs(args, callbacks) {
  return args.map( function (arg) {
    return '{' + arg.toTex(callbacks) + '}';
  }).join(',');
}

//default toTex
function defaultToTex (node, callbacks, name) {
  name = typeof name !== 'undefined' ? name : node.name;
  return '\\mathrm{' + name + '}\\left('
      + functionArgs(node.args, callbacks) + '\\right)';
}

/*
 * expand a template
 *
 * @param {String} template
 * @param {String} name of the function
 * @param {Array} arguments of the function ( Strings )
 **/
function expandTemplate(template, name, args) {
  //replace %name% with the variable 'name'
  template = template.replace(/%name%/g, name);

  //replace %0%, %1% .... with the arguments in args
  args.forEach(function (arg, index) {
    template = template.replace(RegExp('%' + index + '%', 'g'), '{' + arg + '}');
  });
  return template;
}

//this is a map containing all the latex converters for all the functions
var functions = {
  //arithmetic
  'abs': function (node, callbacks) {
    return '\\left|{' + node.args[0].toTex(callbacks) + '}\\right|';
  },
  'add': function (node, callbacks) {
    return '\\left({' + node.args[0].toTex(callbacks)
      + '}' + exports.operators['add'] + '{'
      + node.args[1].toTex(callbacks) + '}\\right)';
  },
  'ceil': function (node, callbacks) {
    return '\\left\\lceil{' + node.args[0].toTex(callbacks) + '}\\right\\rceil';
  },
  'cube': function (node, callbacks) {
    return '\\left({' + node.args[0].toTex(callbacks) + '}\\right)^{3}';
  },
  'divide': function (node, callbacks) {
    return '\\frac{' + node.args[0].toTex(callbacks) <commit_msg>util/latex: New template variable for comma separated list of arguments<commit_after>'use strict';

exports.symbols = {
  // GREEK LETTERS
  Alpha: 'A',     alpha: '\\alpha',
  Beta: 'B',      beta: '\\beta',
  Gamma: '\\Gamma',    gamma: '\\gamma',
  Delta: '\\Delta',    delta: '\\delta',
  Epsilon: 'E',   epsilon: '\\epsilon',  varepsilon: '\\varepsilon',
  Zeta: 'Z',      zeta: '\\zeta',
  Eta: 'H',       eta: '\\eta',
  Theta: '\\Theta',    theta: '\\theta',    vartheta: '\\vartheta',
  Iota: 'I',      iota: '\\iota',
  Kappa: 'K',     kappa: '\\kappa',    varkappa: '\\varkappa',
  Lambda: '\\Lambda',   lambda: '\\lambda',
  Mu: 'M',        mu: '\\mu',
  Nu: 'N',        nu: '\\nu',
  Xi: '\\Xi',       xi: '\\xi',
  Omicron: 'O',   omicron: 'o',
  Pi: '\\Pi',       pi: '\\pi',       varpi: '\\varpi',
  Rho: 'P',       rho: '\\rho',      varrho: '\\varrho',
  Sigma: '\\Sigma',    sigma: '\\sigma',    varsigma: '\\varsigma',
  Tau: 'T',       tau: '\\tau',
  Upsilon: '\\Upsilon',  upsilon: '\\upsilon',
  Phi: '\\Phi',      phi: '\\phi',      varphi: '\\varphi',
  Chi: 'X',       chi: '\\chi',
  Psi: '\\Psi',      psi: '\\psi',
  Omega: '\\Omega',    omega: '\\omega',
  //logic
  'true': '\\mathrm{True}',
  'false': '\\mathrm{False}',
  //other
  i: 'i', //TODO use \i ??
  inf: '\\infty',
  Inf: '\\infty',
  infinity: '\\infty',
  Infinity: '\\infty',
  oo: '\\infty',
  lim: '\\lim',
  'undefined': '\\mathbf{?}'
};

//create a comma separated list of function arguments
function functionArgs(args, callbacks) {
  return args.map( function (arg) {
    return '{' + arg.toTex(callbacks) + '}';
  }).join(',');
}

//default toTex
function defaultToTex (node, callbacks, name) {
  name = typeof name !== 'undefined' ? name : node.name;
  return '\\mathrm{' + name + '}\\left('
      + functionArgs(node.args, callbacks) + '\\right)';
}

/*
 * expand a template
 *
 * @param {String} template
 * @param {String} name of the function
 * @param {Array} arguments of the function ( Strings )
 **/
function expandTemplate(template, name, args) {
  //replace %name% with the variable 'name'
  template = template.replace(/%name%/g, name);

  //replace %0%, %1% .... with the arguments in args
  args.forEach(function (arg, index) {
    template = template.replace(RegExp('%' + index + '%', 'g'), '{' + arg + '}');
  });

  //replace %*% with a comma separated list of all arguments
  template = template.replace('%*%', args.map(function (arg) {
      return '{' + arg + '}';
    }).join(','));

  return template;
}

//this is a map containing all the latex converters for all the functions
var functions = {
  //arithmetic
  'abs': function (node, callbacks) {
    return '\\left|{' + node.args[0].toTex(callbacks) + '}\\right|';
  },
  'add': function (node, callbacks) {
    return '\\left({' + node.args[0].toTex(callbacks)
      + '}' + exports.operators['add'] + '{'
      + node.args[1].toTex(callbacks) + '}\\right)';
  },
  'ceil': function (node, callbacks) {
    return '\\left\\lceil{' + node.args[0].toTex(callbacks) + '}\\right\\rceil';
  },
  'cube': function (node, callbacks) {
    return '\\left({' + node.args[0].toTex(callbacks) + '}\\right)^{3}';
  },
  'divide': function (node, callbacks) {
    return '\\frac{' + node.args[0].toTex(callbacks) 
{'fraction_non_alphanumeric': 0.23763627745299415, 'fraction_numerical': 0.0028440511929214724, 'mean_word_length': 2.65684575389948, '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': '1409598', 'n_tokens_mistral': 2385, 'n_tokens_neox': 2276, 'n_words': 595}