]> gitweb.factorcode.org Git - factor.git/blob - extra/tools/uniq/uniq.factor
Switch to https urls
[factor.git] / extra / tools / uniq / uniq.factor
1 ! Copyright (C) 2011 John Benediktsson
2 ! See https://factorcode.org/license.txt for BSD license
3
4 USING: command-line io io.encodings.utf8 io.files kernel
5 namespaces sets sequences ;
6
7 IN: tools.uniq
8
9 : uniq-lines ( -- )
10     f [
11         2dup = [ dup print ] unless nip
12     ] each-line drop ;
13
14 : uniq-file ( path/f -- )
15     [
16         utf8 [ uniq-lines ] with-file-reader
17     ] [
18         uniq-lines
19     ] if* ;
20
21 : run-uniq ( -- )
22     command-line get [ ?first ] [ ?second ] bi [
23         utf8 [ uniq-file ] with-file-writer
24     ] [
25         uniq-file
26     ] if* ;
27
28 MAIN: run-uniq