Skip to content

Instantly share code, notes, and snippets.

@Jipok
Created September 27, 2017 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jipok/8e85c378da5616fec7d6d314754c65c7 to your computer and use it in GitHub Desktop.
Save Jipok/8e85c378da5616fec7d6d314754c65c7 to your computer and use it in GitHub Desktop.
import os, sets, strutils
if paramCount() != 2:
echo "mydiff file1 file2"
quit()
let file1 = open(paramStr(1))
let file2 = open(paramStr(2))
let old_lines = file1.readAll().splitLines()
let new_lines = file2.readAll().splitLines()
file1.close()
file2.close()
let old_lines_set = toSet(old_lines)
let new_lines_set = toSet(new_lines)
let old_added = old_lines_set - new_lines_set
let old_removed = new_lines_set - old_lines_set
for line in old_lines:
if line in old_added:
echo "-", line.strip()
elif line in old_removed:
echo "+", line.strip()
for line in new_lines:
if line in old_added:
echo "-", line.strip()
elif line in old_removed:
echo "+", line.strip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment