type etat={
  id: int;
  conditions_darrive: (char array) option;
  mutable voisins: (etat array) option;
  terminal:bool;
}

exception Reconnu
  
let reconnaitre automate str=

  let rec reconrec a s k=
    if String.length s = k && a.terminal then
      raise Reconnu
    else
      match a.voisins with
   None -> ()
 | Some vss ->
     for i=0 to (Array.length vss)-1 do
       let v = (Array.get vss i) in
  match v.conditions_darrive with
      None -> reconrec v s k
    | Some cdts ->
        if k>= String.length s then
   ()
        else
   for j=0 to (Array.length cdts)-1 do 
     if ( Char.compare s.[k] (Array.get cdts j) )=0 then
       reconrec v s (k+1)
   done
     done
  in
    try 
      reconrec automate str 0;
      false
    with
 Reconnu -> true

Add a code snippet to your website: www.paste.org