(* filter1.ml - Don Yang (uguu.org) 05/12/02 *) open String;; let a = Sys.argv;; type t = S of string | E;; let rec l i = match (try S (input_line i) with _ -> E) with S x -> [x] @ l i | _ -> [];; let rec r s = let n = length s in if n > 0 then let x = get s (n - 1) in if x == ' ' || x == '\t' then r (sub s 0 (n - 1)) else s else s;; let d = l ( if Array.length a > 1 && a.(1) <> "-" then open_in a.(1) else stdin );; let o = if Array.length a > 2 then open_out a.(2) else stdout;; List.iter (fun x -> output_string o ((r x) ^ "\n")) d;;