File: count_hash.ml

package info (click to toggle)
pcre2-ocaml 8.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 376 kB
  • sloc: ml: 2,626; ansic: 562; makefile: 44
file content (8 lines) | stat: -rw-r--r-- 248 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
open Hashtbl

let hash = create 1973
let add_string s = try incr (find hash s) with Not_found -> add hash s (ref 1)
;;

Pcre2.foreach_line (fun line -> List.iter add_string (Pcre2.split line));
iter (fun k v -> Printf.printf "%4d\t%s\n" !v k) hash