Created
February 24, 2009 23:27
-
-
Save DRMacIver/69872 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let sum = List.fold_left (fun s x -> s + x) 0 | |
| let split = Str.split (Str.regexp_string " ") | |
| let each_line f = | |
| let rec go () = | |
| let _ = f (input_line stdin) in go () | |
| in try go() with End_of_file -> () | |
| let words = Hashtbl.create 8 | |
| let count x = try Hashtbl.find words x with Not_found -> 0 | |
| let inc x = Hashtbl.replace words x (count x + 1);; | |
| each_line inc; | |
| Hashtbl.iter (Printf.printf "%s: %d") words; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment