[gforth] / gforth / sieve.fs  

gforth: gforth/sieve.fs

File: [gforth] / gforth / sieve.fs (download)
Revision: 1.3, Tue Oct 18 15:51:22 1994 UTC (18 years, 8 months ago) by pazsan
Branch: MAIN
CVS Tags: gforth-0_1beta, v0-7-0, v0-4-0, v0-5-0, v0-3-0, v0-2-0, v0-2-1, v0-6-2, v0-6-0, v0-6-1
Changes since 1.2: +1 -1 lines
hash.fs uses single (but large) hash table (like LMI)
time&date bug fixed
ORDER reversed (let's see the reactions)
time printout in sieve.fs fixed
startup.fs modified due to history.fs and doskey.fs (see comment of these
files)

#! /usr/stud/paysan/bin/forth

DECIMAL
: SECS TIME&DATE  2DROP DROP  60 * + 60 * + ;
CREATE FLAGS 8190 ALLOT
FLAGS 8190 + CONSTANT EFLAG

: PRIMES  ( -- n )  FLAGS 8190 1 FILL  0 3  EFLAG FLAGS
  DO   I C@
       IF  DUP I + DUP EFLAG <
           IF    EFLAG SWAP
                 DO  0 I C! DUP  +LOOP
           ELSE  DROP  THEN  SWAP 1+ SWAP
           THEN  2 +
       LOOP  DROP ;

: BENCHMARK  0 100 0 DO  PRIMES NIP  LOOP ;
SECS BENCHMARK . SECS SWAP - CR . .( secs)

\ HPPA/720, 50 MHz: user 3.90s

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help