Advertisement
Wyvern67

Untitled

Apr 7th, 2016
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.85 KB | None | 0 0
  1. type direction = Gauche | Droite;;
  2. type symbole = char;;
  3. type position = int;;
  4. type etat = string;;
  5. type ruban = position -> symbole;;
  6. type etat_global =
  7.     Etat of etat
  8.     | Ruban of ruban
  9.     | Pos of position;;
  10. type regle = etat * symbole * symbole * direction * etat;;
  11. type programme = regle list;;
  12. type tm =
  13.     Programme of programme
  14.     | Ei of etat
  15.     | Efinaux of etat list;;
  16.  
  17. let r' r p s = fun pos -> if p = pos then s else (r pos);;
  18.  
  19. let print_direction d =
  20.     match d with
  21.     | Gauche -> print_string "Gauche"
  22.     | _ -> print_string "Droite";;
  23.  
  24.  
  25.  
  26. let affiche_etat_global eg =
  27.     let rec affiche_helper eg pos =
  28.         if (pos <= 10)
  29.         then
  30.             print_char (eg.Ruban pos);
  31.             affiche_helper eg (pos + 1)
  32.     in
  33.     affiche_helper eg (eg.Pos - 10);;
  34.  
  35. let d = Gauche;;
  36. print_direction d;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement