<commit_before>package thx.core;

/**
Helper functions for functions with arity 0 (functions that do not take arguments).
**/
class Function0 {
  public inline static function join(fa : Void -> Void, fb : Void -> Void)
    return function() {
      fa();
      fb();
    }

  public static function noop() : Void {}

  public inline static function once(f : Void -> Void)
    return function() {
      f();
      f = function(){}
    };
}

/**
Helper functions for functions with arity 1 (functions that take exactly 1 argument).
**/
class Function1 {
  public inline static function compose<TIn, TRet1, TRet2>(fa : TRet2 -> TRet1, fb : TIn -> TRet2)
    return function(v : TIn) return fa(fb(v));

  public static function noop<T>(_ : T) : Void {}

  public inline static function join<TIn>(fa : TIn -> Void, fb : TIn -> Void)
    return function(v : TIn) {
      fa(v);
      fb(v);
    }
}

/**
Generic helper for functions.
**/
class Functions {
  public static function equality<T>(a : T, b : T) return a == b;
}<commit_msg>documented Functions<commit_after>package thx.core;

/**
Helper functions for functions with arity 0 (functions that do not take arguments).
**/
class Function0 {
/**
`join` creates a function that calls the 2 functions passed as arguments in sequence.
**/
  public inline static function join(fa : Void -> Void, fb : Void -> Void)
    return function() {
      fa();
      fb();
    }

/**
`noop` is a function that has no side effects and doesn't return any value.
**/
  public static function noop() : Void {}

/**
`once` wraps and returns the argument function. `once` ensures that `f` will be called
at most once even if the returned function is invoked multiple times.
**/
  public inline static function once(f : Void -> Void)
    return function() {
      var t = f;
      f = noop;
      t();
    };
}

/**
Helper functions for functions with arity 1 (functions that take exactly 1 argument).
**/
class Function1 {
 /**
`compose` returns a function that calls the first arguemnt function with the result
of the following one.
 **/
  public inline static function compose<TIn, TRet1, TRet2>(fa : TRet2 -> TRet1, fb : TIn -> TRet2)
    return function(v : TIn) return fa(fb(v));

/**
`join` creates a function that calls the 2 functions passed as arguments in sequence
and passes the same argument value to the both of them.
**/
  public inline static function join<TIn>(fa : TIn -> Void, fb : TIn -> Void)
    return function(v : TIn) {
      fa(v);
      fb(v);
    }

/**
`noop` is a function that has no side effects and doesn't return any value.
**/
  public static function noop<T>(_ : T) : Void {}

}

/**
Generic helper for functions.
**/
class Functions {
  public static function equality<T>(a : T, b : T) return a == b;
}
{'fraction_non_alphanumeric': 0.12210982658959538, 'fraction_numerical': 0.007947976878612716, 'mean_word_length': 3.084070796460177, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '3796955', 'n_tokens_mistral': 872, 'n_tokens_neox': 827, 'n_words': 348}