tools.uniq: adding "uniq" tool.

db4
John Benediktsson 2015-04-01 14:37:53 -07:00
parent becc1bc728
commit b8cbe9d64d
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1 @@
John Benediktsson

View File

@ -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 }
}

View File

@ -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