From aaa4b2a62f4aae6fe1759b11cf44e59db8eb2cd4 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Wed, 26 Dec 2007 20:35:35 +0100 Subject: [PATCH] Do not use Eratosthene sieve if n < 1e6 since we have a static primes list --- extra/math/erato/erato.factor | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/extra/math/erato/erato.factor b/extra/math/erato/erato.factor index 4993f39e44..9b9ad53469 100644 --- a/extra/math/erato/erato.factor +++ b/extra/math/erato/erato.factor @@ -1,6 +1,7 @@ ! Copyright (c) 2007 Samuel Tardieu. ! See http://factorcode.org/license.txt for BSD license. -USING: bit-arrays kernel lazy-lists math math.functions math.ranges sequences ; +USING: bit-arrays kernel lazy-lists math math.functions math.primes.list + math.ranges sequences ; IN: math.erato : lerato ( n -- lazy-list ) - 2 [ drop next-prime ] curry* lfrom-by [ ] lwhile ; + dup 1000003 < [ + 0 primes-under-million seq>list swap [ <= ] curry lwhile + ] [ + 2 [ drop next-prime ] curry* lfrom-by [ ] lwhile + ] if ;