<commit_before>
(* This file is free software, part of containers. See file "license" for more details. *)

open CCShims_

include CCShimsInt_

type t = int
type 'a iter = ('a -> unit) -> unit

let zero = 0

let one = 1

let minus_one = -1

let add = (+)

let sub = (-)

let mul = ( * )

let div = (/)

let succ = succ

let pred = pred

let abs = abs

let max_int = max_int

let min_int = min_int

let equal (a:int) b = Stdlib.(=) a b

let compare (a:int) b = compare a b

(* use FNV:
   https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function *)
let hash (n:int) : int =
  let offset_basis = 0xcbf29ce484222325L in
  let prime = 0x100000001b3L in

  let h = ref offset_basis in

  for k = 0 to 7 do
    h := Int64.(mul !h prime);
    (* h := h xor (k-th bit of n) *)
    h := Int64.(logxor !h (of_int ((n lsr (k * 8)) land 0xff)));
  done;
  Int64.to_int !h (* truncate back to int *)

let range i j yield =
  let rec up i j yield =
    if i=j then yield i<commit_msg>fix(ccint): make sure hash is always positive<commit_after>
(* This file is free software, part of containers. See file "license" for more details. *)

open CCShims_

include CCShimsInt_

type t = int
type 'a iter = ('a -> unit) -> unit

let zero = 0

let one = 1

let minus_one = -1

let add = (+)

let sub = (-)

let mul = ( * )

let div = (/)

let succ = succ

let pred = pred

let abs = abs

let max_int = max_int

let min_int = min_int

let equal (a:int) b = Stdlib.(=) a b

let compare (a:int) b = compare a b

(* use FNV:
   https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function *)
let hash (n:int) : int =
  let offset_basis = 0xcbf29ce484222325L in
  let prime = 0x100000001b3L in

  let h = ref offset_basis in

  for k = 0 to 7 do
    h := Int64.(mul !h prime);
    (* h := h xor (k-th bit of n) *)
    h := Int64.(logxor !h (of_int ((n lsr (k * 8)) land 0xff)));
  done;
  (Int64.to_int !h) land max_int (* truncate back to int and remove sign *)

let range i j yield =
  let rec up i j yield =
    if i=j then yield i
{'fraction_non_alphanumeric': 0.1280039234919078, 'fraction_numerical': 0.04512015693967631, 'mean_word_length': 2.849056603773585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '3052068', 'n_tokens_mistral': 876, 'n_tokens_neox': 803, 'n_words': 298}