]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.uniq: adding "uniq" tool.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 1 Apr 2015 21:37:53 +0000 (14:37 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 1 Apr 2015 21:37:53 +0000 (14:37 -0700)
extra/tools/uniq/authors.txt [new file with mode: 0644]
extra/tools/uniq/deploy.factor [new file with mode: 0644]
extra/tools/uniq/uniq.factor [new file with mode: 0644]

diff --git a/extra/tools/uniq/authors.txt b/extra/tools/uniq/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/extra/tools/uniq/deploy.factor b/extra/tools/uniq/deploy.factor
new file mode 100644 (file)
index 0000000..62b2611
--- /dev/null
@@ -0,0 +1,15 @@
+USING: tools.deploy.config ;
+H{
+    { deploy-name "uniq" }
+    { deploy-ui? f }
+    { deploy-c-types? f }
+    { deploy-console? t }
+    { deploy-unicode? f }
+    { "stop-after-last-window?" t }
+    { deploy-io 3 }
+    { deploy-reflection 6 }
+    { deploy-word-props? f }
+    { deploy-math? t }
+    { deploy-threads? t }
+    { deploy-word-defs? f }
+}
diff --git a/extra/tools/uniq/uniq.factor b/extra/tools/uniq/uniq.factor
new file mode 100644 (file)
index 0000000..f2c5cb6
--- /dev/null
@@ -0,0 +1,28 @@
+! Copyright (C) 2011 John Benediktsson
+! See http://factorcode.org/license.txt for BSD license
+
+USING: command-line io io.encodings.utf8 io.files kernel
+namespaces sets sequences ;
+
+IN: tools.uniq
+
+: uniq-lines ( -- )
+    f [
+        2dup = [ dup print ] unless nip
+    ] each-line drop ;
+
+: uniq-file ( path/f -- )
+    [
+        utf8 [ uniq-lines ] with-file-reader
+    ] [
+        uniq-lines
+    ] if* ;
+
+: run-uniq ( -- )
+    command-line get [ ?first ] [ ?second ] bi [
+        utf8 [ uniq-file ] with-file-writer
+    ] [
+        uniq-file
+    ] if* ;
+
+MAIN: run-uniq