dictionary - with exc -> close_in file; raise...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
let rec chars_of_string s = let len = String.length s in if len = 0 then [] else (s.[0])::(chars_of_string (String.sub s (1) (len-1))) let fold_lines f accum fname = let file = open_in fname in try let rec read_lines accum = let res = try Some (input_line file) with End_of_file -> None in match res with None -> accum | Some line -> read_lines (f line accum) in read_lines accum
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: with exc -> close_in file; raise exc let read_dictionary file_name = let inserter s t = match s.[0] with 'A'. .'Z' -> t | _ -> if String.length s < 3 then t else Trie.put (t) (chars_of_string s) (true) in fold_lines inserter Trie.empty file_name...
View Full Document

This note was uploaded on 10/25/2009 for the course CS 3110 at Cornell University (Engineering School).

Ask a homework question - tutors are online