]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/benchmark/knucleotide/knucleotide.factor
factor: trim using lists
[factor.git] / extra / benchmark / knucleotide / knucleotide.factor
index 241932215206ff3036db5c1185dabf631e14a4a4..2ba6b433cf2e6cb02097f821d822db55c3c9cff6 100644 (file)
@@ -1,9 +1,7 @@
 ! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: ascii kernel io io.files splitting strings
-io.encodings.ascii hashtables sequences assocs math
-math.statistics namespaces math.parser combinators arrays
-sorting formatting grouping fry ;
+USING: ascii assocs formatting grouping io io.encodings.ascii
+io.files kernel math math.statistics sequences ;
 IN: benchmark.knucleotide
 
 CONSTANT: knucleotide-in "vocab:benchmark/knucleotide/knucleotide-input.txt"
@@ -18,15 +16,15 @@ CONSTANT: knucleotide-in "vocab:benchmark/knucleotide/knucleotide-input.txt"
     CHAR: \n swap remove >upper ;
 
 : handle-table ( inputs n -- )
-    <clumps>
-    [ histogram sort-values reverse ] [ length ] bi
+    clump
+    [ sorted-histogram reverse ] [ length ] bi
     '[
         [ first write bl ]
         [ second 100 * _ /f "%.3f" printf nl ] bi
     ] each ;
 
 : handle-n ( input x -- )
-    [ nip ] [ length <clumps> histogram ] 2bi at 0 or "%d\t" printf ;
+    [ nip ] [ length clump histogram ] 2bi at 0 or "%d\t" printf ;
 
 : process-input ( input -- )
     [ 1 handle-table nl ]
@@ -37,9 +35,9 @@ CONSTANT: knucleotide-in "vocab:benchmark/knucleotide/knucleotide-input.txt"
     ]
     tri ;
 
-: knucleotide ( -- )
+: knucleotide-benchmark ( -- )
     knucleotide-in
     ascii [ read-input ] with-file-reader
     process-input ;
 
-MAIN: knucleotide
+MAIN: knucleotide-benchmark