         :> alu
         0 :> k!
         [| len | k len alu make-repeat-fasta k! ] split-lines
-    ] ; inline
+    ] ;
 
 : fasta ( n out -- )
     homo-sapiens make-cumulative

        { CHAR: t 0.3015094502008 }
    }

: make-cumulative ( freq -- chars floats )
    [ keys >byte-array ]
    [ values >double-array ] bi unclip [ + ] accumulate swap suffix ;

:: select-random ( seed chars floats -- seed elt )
    floats seed random -rot
    [ >= ] curry find drop
    chars nth-unsafe ; inline

: make-random-fasta ( seed len chars floats -- seed )
    [ iota ] 2dip [ [ drop ] 2dip select-random ] 2curry "" map-as print ; inline

: write-description ( desc id -- )
    ">" write write bl print ; inline

:: split-lines ( n quot -- )
    n line-length /mod
    [ [ line-length quot call ] times ] dip
    quot unless-zero ; inline

: write-random-fasta ( seed n chars floats desc id -- seed )
    write-description
    [ make-random-fasta ] 2curry split-lines ; inline

:: make-repeat-fasta ( k len alu -- k' )
    alu length :> kn
    len iota [ k + kn mod alu nth-unsafe ] "" map-as print
    k len + ; inline

: write-repeat-fasta ( n alu desc id -- )
    write-description

! Based on http://shootout.alioth.debian.org/gp4/benchmark.php?test=fasta&lang=java&id=2
USING: assocs benchmark.reverse-complement byte-arrays fry io
io.encodings.ascii io.files locals kernel math sequences
sequences.private specialized-arrays strings typed ;
QUALIFIED-WITH: alien.c-types c
SPECIALIZED-ARRAY: c:double
IN: benchmark.fasta

CONSTANT: IM 139968
