file_intersection.sf 361 B

1234567891011121314151617181920
  1. #!/usr/bin/ruby
  2. # Show the unique lines from file 1 that also exist in file 2.
  3. var file1 = File(ARGV[0])
  4. var file2 = File(ARGV[1])
  5. func collect_lines(fh) {
  6. var list = Set()
  7. fh.each {|line|
  8. #list << line.words.last
  9. list << line
  10. }
  11. list
  12. }
  13. collect_lines(file1.open_r) & collect_lines(file2.open_r) -> each {|line|
  14. say line
  15. }