 ! Copyright (C) 2007-2009 Samuel Tardieu.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators kernel math math.bitwise math.functions
+USING: combinators fry kernel math math.bitwise math.functions
 math.order math.primes.erato math.primes.erato.private
-math.primes.miller-rabin math.ranges literals random sequences sets ;
+math.primes.miller-rabin math.ranges literals random sequences sets
+vectors ;
 IN: math.primes
 
 <PRIVATE


: (prime?) ( n -- ? )
    dup 8999999 <= [ look-in-bitmap ] [ miller-rabin ] if ;

PRIVATE>


    ] if ; foldable

: primes-between ( low high -- seq )
    [ [ 3 max dup even? [ 1 + ] when ] dip 2 <range> ]
    [ <primes-vector> ] 2bi
    [ '[ [ prime? ] _ push-if ] each ] keep clone ;

: primes-upto ( n -- seq ) 2 swap primes-between ;

