(* Read from stdin to list of tuples *) let rec read_stdin () = try let line = read_line () in Scanf.sscanf line "%s %d %s %d" (fun d c s y -> (d,c,s,y)) :: read_stdin () with End_of_file -> [] ;; (* Print a tuple *) let print_info (d,c,s,y) = Printf.printf "Department: %s\nCourse: %d\nSemester: %s\nYear: %d\n\n" d c s y ;; (* Read list and save to l *) let l = read_stdin ();; (* Call print_info for each tuple in the list *) List.map print_info l