<commit_before>package thx;

@:forward(length, copy, filter, indexOf, iterator, join, lastIndexOf,
          map, slice, toString)
abstract ReadonlyArray<T>(Array<T>) from Array<T> {
  inline public static function empty<T>() : ReadonlyArray<T>
    return [];

  @:arrayAccess
  inline function get(index : Int)
    return this[index];

  inline public function toArray() : Array<T>
    return this.copy();

  inline public function unsafe() : Array<T>
    return this;

  inline public function concat(that : ReadonlyArray<T>) : ReadonlyArray<T>
    return this.concat(that.unsafe());

  inline public function insertAt(pos : Int, el : T) : ReadonlyArray<T>
    return this.slice(0, pos).concat([el]).concat(this.slice(pos));

  inline public function replaceAt(pos : Int, el : T) : ReadonlyArray<T>
    return this.slice(0, pos).concat([el]).concat(this.slice(pos + 1));

  inline public function prepend(el : T) : ReadonlyArray<T>
    return ([el] : ReadonlyArray<T>).concat(this);

  inline public function append(el : T) : ReadonlyArray<T>
    return this.concat([el]);
}
<commit_msg>exposed indexOf equality function<commit_after>package thx;

import thx.Functions;

@:forward(length, copy, filter, iterator, join, lastIndexOf,
          map, slice, toString)
abstract ReadonlyArray<T>(Array<T>) from Array<T> {
  inline public static function empty<T>() : ReadonlyArray<T>
    return [];

  public function indexOf(el : T, ?eq : T -> T -> Bool) : Int {
    if(null == eq) eq = Functions.equality;
    for(i in 0...this.length)
      if(eq(el, this[i]))
        return i;
    return -1;
  }

  @:arrayAccess
  inline function get(index : Int)
    return this[index];

  inline public function toArray() : Array<T>
    return this.copy();

  inline public function unsafe() : Array<T>
    return this;

  inline public function concat(that : ReadonlyArray<T>) : ReadonlyArray<T>
    return this.concat(that.unsafe());

  inline public function insertAt(pos : Int, el : T) : ReadonlyArray<T>
    return this.slice(0, pos).concat([el]).concat(this.slice(pos));

  inline public function replaceAt(pos : Int, el : T) : ReadonlyArray<T>
    return this.slice(0, pos).concat([el]).concat(this.slice(pos + 1));

  inline public function prepend(el : T) : ReadonlyArray<T>
    return ([el] : ReadonlyArray<T>).concat(this);

  inline public function append(el : T) : ReadonlyArray<T>
    return this.concat([el]);
}

{'fraction_non_alphanumeric': 0.14208782104391052, 'fraction_numerical': 0.0033140016570008283, 'mean_word_length': 4.041753653444676, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, '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': '5798213', 'n_tokens_mistral': 787, 'n_tokens_neox': 759, 'n_words': 210}