Comment detail

ファイル内の重複行削除(後優先) (Nested Flatten)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
let mem s ic =
  try while s <> input_line ic do () done; true
  with End_of_file -> false;;

let uniq ic oc =
  try 
    while true do
      let s = input_line ic in
      let current_pos = pos_in ic in
      if mem s ic then () else output_string oc (s ^ "\n");
      seek_in ic current_pos;
    done
  with End_of_file -> flush oc;;

let main in_file out_file =
  let i = open_in in_file
  and o = open_out out_file in
  uniq i o; close_in i; close_out o;;

(* main "in.txt" "out.txt";; *)

Index

Feed

Other

Link

Pathtraq

loading...