Remove unused and redundant math.erato
The math.erato module brings nothing more is brought by lprimes from math.primes. Remove it, as it has no user, and a better version is available in math.primes.erato anyway.db4
parent
99023a3322
commit
5a9eab2c48
|
@ -1,6 +0,0 @@
|
||||||
USING: help.markup help.syntax ;
|
|
||||||
IN: math.erato
|
|
||||||
|
|
||||||
HELP: lerato
|
|
||||||
{ $values { "n" "a positive number" } { "lazy-list" "a lazy prime numbers generator" } }
|
|
||||||
{ $description "Builds a lazy list containing the prime numbers between 2 and " { $snippet "n" } " (inclusive)." } ;
|
|
|
@ -1,6 +0,0 @@
|
||||||
! Copyright (c) 2007 Samuel Tardieu.
|
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
|
||||||
USING: lists.lazy math.erato tools.test ;
|
|
||||||
IN: math.erato.tests
|
|
||||||
|
|
||||||
[ { 2 3 5 7 11 13 17 19 } ] [ 20 lerato list>array ] unit-test
|
|
|
@ -1,43 +0,0 @@
|
||||||
! Copyright (c) 2007 Samuel Tardieu.
|
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
|
||||||
USING: accessors bit-arrays fry kernel lists.lazy math math.functions
|
|
||||||
math.primes.list math.ranges sequences ;
|
|
||||||
IN: math.erato
|
|
||||||
|
|
||||||
<PRIVATE
|
|
||||||
|
|
||||||
TUPLE: erato limit bits latest ;
|
|
||||||
|
|
||||||
: ind ( n -- i )
|
|
||||||
2/ 1- ; inline
|
|
||||||
|
|
||||||
: is-prime ( n limit -- bool )
|
|
||||||
[ ind ] [ bits>> ] bi* nth ; inline
|
|
||||||
|
|
||||||
: indices ( n erato -- range )
|
|
||||||
limit>> ind over 3 * ind spin <range> ;
|
|
||||||
|
|
||||||
: mark-multiples ( n erato -- )
|
|
||||||
2dup [ sq ] [ limit>> ] bi* <= [
|
|
||||||
[ indices ] keep bits>> '[ _ f -rot set-nth ] each
|
|
||||||
] [ 2drop ] if ;
|
|
||||||
|
|
||||||
: <erato> ( n -- erato )
|
|
||||||
dup ind 1+ <bit-array> dup set-bits 1 erato boa ;
|
|
||||||
|
|
||||||
: next-prime ( erato -- prime/f )
|
|
||||||
[ 2 + ] change-latest [ latest>> ] keep
|
|
||||||
2dup limit>> <= [
|
|
||||||
2dup is-prime [ dupd mark-multiples ] [ nip next-prime ] if
|
|
||||||
] [
|
|
||||||
2drop f
|
|
||||||
] if ;
|
|
||||||
|
|
||||||
PRIVATE>
|
|
||||||
|
|
||||||
: lerato ( n -- lazy-list )
|
|
||||||
dup 1000003 < [
|
|
||||||
0 primes-under-million seq>list swap '[ _ <= ] lwhile
|
|
||||||
] [
|
|
||||||
<erato> 2 [ drop next-prime ] with lfrom-by [ ] lwhile
|
|
||||||
] if ;
|
|
Loading…
Reference in New Issue