<commit_before>(*
** Implementing the doublet game
*)

(* ****** ****** *)
//
#include
"share/atspre_staload.hats"
//
(* ****** ****** *)
//
staload UN =
"prelude/SATS/unsafe.sats"
//
(* ****** ****** *)
//
staload
"libats/ML/SATS/basis.sats"
staload
"libats/ML/SATS/strarr.sats"
//
(* ****** ****** *)

staload "./doublet.sats"

(* ****** ****** *)

staload _ = "libats/ML/DATS/array0.dats"
staload _ = "libats/ML/DATS/strarr.dats"

(* ****** ****** *)
//
extern
fun
word_get_friends_at
  (w0: word, i: size_t): List0_vt (word)
//
(* ****** ****** *)

implement
word_get_friends_at
  (w0, i0) = let
//
vtypedef res = List0_vt (word)
//
val n0 = length (w0)
val c0 = strarr_get_at (w0, i0)
//
fun aux1
(
  c: char, res: res
) : res =
  if c < c0 then let
    val w = w where
    {
      val f =
      lam (i: size_t)
        : char =<cloref1> if i != i0 then w0[i] else c
      val w = strarr_tabulate (n0, f)
      val () = cloptr_free ($UN.castvwtp0{cloptr(void)}(f))
    }
    val res = aux1 (int2char0(char2int0(c)+1), res)
  in
    if word_is_legal(w) then list_vt_cons (w, res) else res
  end else res // end of [if]<commit_msg>Updating: very very minorly<commit_after>(*
** Implementing the doublet game
*)

(* ****** ****** *)
//
#include
"share/atspre_staload.hats"
//
(* ****** ****** *)
//
staload UN =
"prelude/SATS/unsafe.sats"
//
(* ****** ****** *)
//
staload
"libats/ML/SATS/basis.sats"
staload
"libats/ML/SATS/strarr.sats"
//
(* ****** ****** *)

staload "./doublet.sats"

(* ****** ****** *)

staload _ = "libats/ML/DATS/array0.dats"
staload _ = "libats/ML/DATS/strarr.dats"

(* ****** ****** *)
//
extern
fun
word_get_friends_at
  (w0: word, i: size_t): List0_vt (word)
//
(* ****** ****** *)

implement
word_get_friends_at
  (w0, i0) = let
//
vtypedef
res = List0_vt(word)
//
val n0 = g1ofg0(length(w0))
val c0 = strarr_get_at(w0, i0)
//
fun aux1
(
  c: char, res: res
) : res =
  if c < c0 then let
    val w = w where
    {
      val f =
      lam (i: size_t)
        : char =<cloref1> if i != i0 then w0[i] else c
      val w = strarr_tabulate(n0, f)
      val () = cloptr_free ($UN.castvwtp0{cloptr(void)}(f))
    }
    val res = aux1 (int2char0(char2int0(c)+1), res)
  in
    if word_is_legal(w) then list_vt_cons (w, res) else res
  end else res // end of [if]
{'fraction_non_alphanumeric': 0.2331583552055993, 'fraction_numerical': 0.021872265966754154, 'mean_word_length': 2.9567474048442905, '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': '7045950', 'n_tokens_mistral': 1037, 'n_tokens_neox': 1028, 'n_words': 208}