-USING: ascii kernel io io.files splitting strings
-io.encodings.ascii hashtables sequences assocs math
-math.statistics namespaces prettyprint math.parser combinators
-arrays sorting formatting grouping fry ;
+! Copyright (C) 2008, 2010 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+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"
+
: discard-lines ( -- )
readln
[ ">THREE" head? [ discard-lines ] unless ] when* ;
: handle-table ( inputs n -- )
clump
- [ histogram >alist sort-values reverse ] [ length ] bi
+ [ sorted-histogram reverse ] [ length ] bi
'[
[ first write bl ]
[ second 100 * _ /f "%.3f" printf nl ] bi
]
tri ;
-: knucleotide ( -- )
- "resource:extra/benchmark/knucleotide/knucleotide-input.txt"
+: knucleotide-benchmark ( -- )
+ knucleotide-in
ascii [ read-input ] with-file-reader
process-input ;
-MAIN: knucleotide
+MAIN: knucleotide-benchmark