<commit_before>(*
 * fibo.sml
 * calcul des nombres de Fibonacci avec memoïzation
 * calcul jusqu'à 46 pour les entiers 32 bits
 *)


open BtIO;

exception BadArgument;
exception NegativeArgument;
exception NoArgument;

fun fibo_maker n =
let
  val  fibo_values : IntInf.int option array = Array.array(n+1, NONE);

  val _ = Array.update(fibo_values, 0, SOME 0)
  val _ = Array.update(fibo_values, 1, SOME 1);
  val _ = Array.update(fibo_values, 2, SOME 2);

  fun get_fibo 1 = 1
    | get_fibo 2 = 1
    | get_fibo k =
    case Array.sub (fibo_values, k)
      of SOME r => r
       | NONE =>
           let
             val f = get_fibo (k - 1) + get_fibo (k - 2);
           in
             Array.update (fibo_values, k, SOME f);
             f
           end
in
  get_fibo
end;

fun get_fact_arg [] = raise NoArgument
  | get_fact_arg (h::t) = 
  case (Int.fromString h)
    of NONE => raise BadArgument
     | SOME m => if m > 0<commit_msg>correction petit bug pour les petites valeurs de N<commit_after>(*
 * fibo.sml
 * calcul des nombres de Fibonacci avec memoïzation
 * calcul jusqu'à 46 pour les entiers 32 bits
 *)


open BtIO;

exception BadArgument;
exception NegativeArgument;
exception NoArgument;

fun fibo_maker n =
let
  val array_dim = if n > 2
                  then n + 1
                  else 3

  val  fibo_values : IntInf.int option array = Array.array(array_dim, NONE);

  val _ = Array.update(fibo_values, 0, SOME 0)
  val _ = Array.update(fibo_values, 1, SOME 1);
  val _ = Array.update(fibo_values, 2, SOME 2);

  fun get_fibo 1 = 1
    | get_fibo 2 = 1
    | get_fibo k =
    case Array.sub (fibo_values, k)
      of SOME r => r
       | NONE =>
           let
             val f = get_fibo (k - 1) + get_fibo (k - 2);
           in
             Array.update (fibo_values, k, SOME f);
             f
           end
in
  get_fibo
end;

fun get_fact_arg [] = raise NoArgument
  | get_fact_arg (h::t) = 
  case (Int.fromString h)
    of NONE => raise BadArgument
     | SOME m => if m > 0
{'fraction_non_alphanumeric': 0.09429280397022333, 'fraction_numerical': 0.018858560794044667, 'mean_word_length': 2.194928684627575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '5748513', 'n_tokens_mistral': 797, 'n_tokens_neox': 715, 'n_words': 231}