<commit_before>package thx;

using thx.Arrays;
using thx.Strings;
using StringTools;

/**
Extension methods for integer values.
**/
class Ints {
  static var pattern_parse = ~/^\s*[+-]?(\d+|0x[0-9A-F]+)/i;
/**
`abs` returns the absolute integer value of the passed argument.
**/
  inline public static function abs(v : Int) : Int
    return v < 0 ? -v : v;

/**
`canParse` takes a string and return a boolean indicating if the argument can be safely transformed
into a valid integer value.
**/
  public static function canParse(s : String)
    return pattern_parse.match(s);

/**
`clamp` restricts a value within the specified range.
**/
  public static inline function clamp(v : Int, min : Int, max : Int) : Int
    return v < min ? min : (v > max ? max : v);

/**
Like clamp but you only pass one argument (`max`) that is used as the upper limit
and the opposite (additive inverse or `-max`) as the lower limit.
**/
  public static inline function clampSym(v : Int, max : Int) : Int
    return clamp(v, -max, max);

/**<commit_msg>fixed thx.Ints at macro time (closes issue #81)<commit_after>package thx;

using thx.Arrays;
using thx.Strings;
using StringTools;

/**
Extension methods for integer values.
**/
class Ints {
  static var pattern_parse = ~/^[ \t\r\n]*[+-]?(\d+|0x[0-9A-F]+)/i;
/**
`abs` returns the absolute integer value of the passed argument.
**/
  inline public static function abs(v : Int) : Int
    return v < 0 ? -v : v;

/**
`canParse` takes a string and return a boolean indicating if the argument can be safely transformed
into a valid integer value.
**/
  public static function canParse(s : String)
    return pattern_parse.match(s);

/**
`clamp` restricts a value within the specified range.
**/
  public static inline function clamp(v : Int, min : Int, max : Int) : Int
    return v < min ? min : (v > max ? max : v);

/**
Like clamp but you only pass one argument (`max`) that is used as the upper limit
and the opposite (additive inverse or `-max`) as the lower limit.
**/
  public static inline function clampSym(v : Int, max : Int) : Int
    return clamp(v, -max, max);

/**
{'fraction_non_alphanumeric': 0.12814428096820124, 'fraction_numerical': 0.004746084480303749, 'mean_word_length': 3.5042735042735043, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '6910931', 'n_tokens_mistral': 669, 'n_tokens_neox': 661, 'n_words': 279}