This preview shows page 1. Sign up to view the full content.
Unformatted text preview: and dictionary = Dictionary.read_dictionary dict_file in let width = Board.width board in let rec solveHelper x y = let newList = if (x+1) = width then (if (y+1) = width then else solveHelper 0 (y+1)) else solveHelper (x+1) y in (findWords x y board dictionary) @ newList in let (_, wds) = List.fold_left (fun (last, acc) w -> if last = w then (last, acc) else (w, w::acc)) ("", ) (List.sort String.compare (solveHelper 0 0)) in let oc = open_out out_file in try List.iter (fun s -> output_string oc (s ^ "\n"); flush oc) (List.rev wds); close_out oc with e -> close_out_noerr oc; raise e...
View Full Document
This note was uploaded on 10/25/2009 for the course CS 3110 at Cornell University (Engineering School).