title: prompt user to build a string list
body: <p>I would like to build a string list by prompting the user for input. My end goal is to be able to parse a string list against a simple hash table using a simple routine. </p>
  
  <pre><code>`let list_find tbl ls = 
     List.iter (fun x -&gt; 
       let mbr = if Hashtbl.mem tbl x then "aok" else "not found"
       in 
       Printf.printf "%s %s\n" x mbr) ls ;;`
  </code></pre>
  
  <p>Building a string list is accomplished with the cons operator ::, but somehow I am not able to get the prompt to generate a string list. A simpe list function returns anything that is put into it as a list:</p>
  
  <pre><code>`let build_strlist x = 
      let rec aux x = match x with
        | [] -&gt; []
        | hd :: tl -&gt; hd :: aux tl
      in
      aux x ;;`
  </code></pre>
  
  <p>Thus far, I have been able to set the prompt, but building the string list did not go so well. I am inclined to think I should be using Buffer or Scanning.in_channel. This is what I have thus far:</p>
  
  <pre><code>`#load "unix.cma" ;;
   let prompt () = Unix.isatty Unix.stdin &amp;&amp; Unix.isatty Unix.stdout ;;
  
   let build_strlist () = 
     let rec loop () = 
     let eof  = ref false in 
       try
         while not !eof do
           if prompt () then print_endline "enter input ";
           let line = read_line () in 
             if line = "-1" then eof := true
             else
               let rec build x = match x with
                 | [] -&gt; []
                 | hd :: tl -&gt; hd :: build tl
               in
               Printf.printf "you've entered %s\n" (List.iter (build line));
          done
        with End_of_file -&gt; ()
   in
   loop () ;;`
  </code></pre>
  
  <p>I am getting an error the keyword "line" has the type string, but an expression was expected of type 'a list. Should I be building the string list using Buffer.create buf and then Buffer.add_string buf prepending [ followed by quotes " another " and a semicolon? This seems to be an overkill. Maybe I should just return a string list and ignore any attempts to "peek at what we have"? Printing will be done after checking the hash table.</p>
  
  <p>I would like to have a prompt routine so that I can use ocaml for scripting and user interaction. I found some ideas on-line which allowed me to write the skeleton above.</p>