<commit_before>// _math.scss contains basic math function.

// gcd
// stands for Greatest Common Divisor.
//    gcd(8, 12)  -> 4
//    gcd(15, 5)  -> 5
//    gcd(81, 27) -> 27
//    gcd(32, 65) -> 1
// http://rosettacode.org/wiki/Greatest_common_divisor#JavaScript
@function gcd($a, $b) {
  @if ($b != 0) {
    @return gcd($b, $a % $b);
  } @else {
    @return abs($a);
  }
}

// pow
// returns the base to the exponent power, that is, raises a number to the power.
//    pow(2, 2) -> 4
//    pow(2, 3) -> 8
//    pow(2, 4) -> 16
//    pow(3, 2) -> 9
@function pow($base, $exp, $prec: 12) {
  // Handles decimal exponents by trying to convert them into a fraction
  @if (floor($exp) != $exp) {
    $prec2 : pow(10, $prec);
    $exp: round($exp * $prec2);
    $denominator: gcd($exp, $prec2);
    @return root(pow($base, $exp / $denominator), $prec2 / $denominator, $prec);
  }

  $value: $base;
  @if $exp > 1 {
    @for $i from 2 through $exp {
      $value: $value * $base;
    }
  } @else if $exp < 1 {
    @for $i from 0 through -$exp {
      $value: $value / $base;
    }
  }

  @return $value;
}

// root
// takes root of a number.
//    root(8, 3)  -> 2
//    root(9)     -> 3
// http://rosettacode.org/wiki/Nth_root#JavaScript
@function root($num, $n: 2, $prec: 12) {
  $x: 1;
  @for $i from 0 through $prec {
    $x: 1 / $n * (($n - 1) * $x + ($num / pow($x, $n - 1)));
  }
  @return $x;
}

// limit
// limits $val within the $min, $max range.
//    limit(300, 0, 255)  -> 255
//    limit(-300, 0, 255) -> 0
@function limit($val, $min, $max) {
  @if $val < $min { @return $min; }
  @if $val > $max { @return $max; }
  @return $val;
}<commit_msg>Add scale(), max(), min() functions<commit_after>// _math.scss contains basic math function.

// gcd
// stands for Greatest Common Divisor.
//    gcd(8, 12)  -> 4
//    gcd(15, 5)  -> 5
//    gcd(81, 27) -> 27
//    gcd(32, 65) -> 1
// http://rosettacode.org/wiki/Greatest_common_divisor#JavaScript
@function gcd($a, $b) {
  @if ($b != 0) {
    @return gcd($b, $a % $b);
  } @else {
    @return abs($a);
  }
}

// pow
// returns the base to the exponent power, that is, raises a number to the power.
//    pow(2, 2) -> 4
//    pow(2, 3) -> 8
//    pow(2, 4) -> 16
//    pow(3, 2) -> 9
@function pow($base, $exp, $prec: 12) {
  // Handles decimal exponents by trying to convert them into a fraction
  @if floor($exp) != $exp {
    $prec2 : pow(10, $prec);
    $exp: round($exp * $prec2);
    $denominator: gcd($exp, $prec2);
    @return root(pow($base, $exp / $denominator), $prec2 / $denominator, $prec);
  }

  $value: $base;
  @if $exp > 1 {
    @for $i from 2 through $exp {
      $value: $value * $base;
    }
  } @else if $exp < 1 {
    @for $i from 0 through -$exp {
      $value: $value / $base;
    }
  }

  @return $value;
}

// root
// takes root of a number.
//    root(8, 3)  -> 2
//    root(9)     -> 3
// http://rosettacode.org/wiki/Nth_root#JavaScript
@function root($num, $n: 2, $prec: 12) {
  $x: 1;
  @for $i from 0 through $prec {
    $x: 1 / $n * (($n - 1) * $x + ($num / pow($x, $n - 1)));
  }
  @return $x;
}

// limit
// limits $val within the $min, $max range.
//    limit(300, 0, 255)  -> 255
//    limit(-300, 0, 255) -> 0
@function limit($val, $min, $max) {
  @if $val < $min { @return $min; }
  @if $val > $max { @return $max; }
  @return $val;
}

// scale
// fluidly scales $val within the $min, $max range.
//    scale(10, +100, 0, 100) -> 100
//    scale(10, +20, 0, 100)  -> 28
//    scale(10, -20, 0, 100)  -> 8
//    scale(10, -100, 0, 100) -> 0
@function scale($val, $amount, $min:0, $max:100) {
  @if $amount > 0 {
    $val: $val + ($max - $val) * ($amount / 100.0);
    @if $val > $max {
      $val: $max;
    }
  } @else if $amount < 0 {
    $val: $val + ($val * $amount / 100.0);
    @if $val < $min {
      $val: $min;
    }
  }
  @return $val;
}

// max
// return the maximum value
@function max($args...) {
  $max: nth($args, 1);
  @each $a in $args {
    $max: if($a > $max, $a, $max);
  }
  @return $max;
}

// min
// return the minimum value
@function min($args...) {
  $min: nth($args, 1);
  @each $a in $args {
    $min: if($a < $min, $a, $min);
  }
  @return $min;
}
{'fraction_non_alphanumeric': 0.21976967370441458, 'fraction_numerical': 0.05014395393474088, 'mean_word_length': 2.2143407864302236, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 38, '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': '1948165', 'n_tokens_mistral': 1902, 'n_tokens_neox': 1719, 'n_words': 510}