src/Pure/POLY.ML
changeset 396 18c9c28d0f7e
parent 378 85ff48546a05
child 1289 2edd7a39d92a
equal deleted inserted replaced
395:712dceb1ecc7 396:18c9c28d0f7e
    48                                  else ([x], sffx)
    48                                  else ([x], sffx)
    49        | (prfx, sffx) => (x :: prfx, sffx));
    49        | (prfx, sffx) => (x :: prfx, sffx));
    50 
    50 
    51 fun apr (f,y) x = f(x,y);
    51 fun apr (f,y) x = f(x,y);
    52 
    52 
       
    53 fun seq (proc: 'a -> unit) : 'a list -> unit =
       
    54   let fun seqf [] = ()
       
    55         | seqf (x :: xs) = (proc x; seqf xs)
       
    56   in seqf end;
       
    57 
    53 in
    58 in
    54 
    59 
    55 (*Get a string containing the time of last modification, attributes, owner
    60 (*Get a string containing the time of last modification, attributes, owner
    56   and size of file (but not the path) *)
    61   and size of file (but not the path) *)
    57 fun file_info "" = ""
    62 fun file_info "" = ""
    81   in close_in is;
    86   in close_in is;
    82      close_out os;
    87      close_out os;
    83      implode path
    88      implode path
    84   end;
    89   end;
    85 
    90 
    86 end;
       
    87 
       
    88 
    91 
    89 (*** ML command execution ***)
    92 (*** ML command execution ***)
    90 
    93 
    91 fun use_string commands =
    94 val use_string =
    92   let val firstLine = ref true;
    95   let fun exec command =
    93       fun getLine () =
    96     let val firstLine = ref true;
    94         if !firstLine
    97 
    95         then (firstLine := false; commands ^ ";\n")
    98         fun getLine () =
    96         else raise Io "execML: buffer exhausted"
    99           if !firstLine
    97   in PolyML.compiler (getLine, fn s => output (std_out, s)) () end;
   100           then (firstLine := false; command)
       
   101           else raise Io "use_string: buffer exhausted"
       
   102     in PolyML.compiler (getLine, fn s => output (std_out, s)) () end
       
   103   in seq exec end;
       
   104 
       
   105 end;