huffmann.ml 375 B

1234567891011121314151617
  1. type suite = char list;;
  2. type code = bool list;;
  3. type cle = (char * code) list;;
  4. let coder (s:suite) (c:cle)=
  5. let rec code_of_char t cl = match cl with
  6. | [] -> failwith "Erreur dans coder"
  7. | (x,l)::r -> if x=t then l
  8. else code_of_char t r
  9. and coder_aux ss = match ss with
  10. | [] -> []
  11. | t::q -> (code_of_char t c)@(coder_aux q)
  12. in coder_aux s ;;