Hello

When running this I would expect the 2 files to
look the same, but they don't.

<CODE>
        new P0, .PerlArray   # PMC creation

        set I10, 10000 # wanted numbers. this fails, 1000 works
        
        set P0, I10            # set array size
        
        set P0[0], 2          # set array position 1
        set P0[1], 3          # set array position 2
        
        time I3
        dec I10

        set I0, 3   # i
        set I2, 1   # found numbers

NUMBER:
        ge I2, I10, DONE
        add I0, I0, 2
        set I1, 0    # j
        pow N0, I0, 0.5
        set I4, N0  # sqrt
        dec I4

UNTIL:
        set I6, P0[I1]
        gt I6, I4, PRIME
        inc I1
        set I6, P0[I1]
        mod I5, I0, I6
        unless I5, NUMBER
        branch UNTIL

PRIME:
        inc I2
        set P0[I2], I0
        branch NUMBER

DONE:
        set S0, "a_file"
        open P1, S0
        set I0, 0
LOOP:
        gt I0, I10, EXIT
        set I2, P0[I0]
        set S1, I2
        concat S1, S1, " "
        print P1, S1
        print S1
        inc I0
        mod I6, I0, 19
        unless I6, NEW_L
        branch LOOP
NEW_L:
        print P1, "\n"
        print "\n"
        branch LOOP

EXIT:
        print P1, "\n"
        print "\n"
        close P1
        time I4
        sub I0, I4, I3
        #print I0
        #print "\n"
        end
</CODE>

[stefan Thu  7:17:58 1 my_parrot]$ parrot primes.pasm > b_file
[stefan Thu  7:18:12 1 my_parrot]$ wc a_file b_file 
    527    9999   59489 a_file
    527   10000   59509 b_file
   1054   19999  118998 total
[stefan Thu  7:18:58 1 my_parrot]$ grep \\b13417\\b a_file b_file #           ||
a_file:13291 13297 13309 13313 13327 13331 13337 13339 13367 13381 13397 13399 
13417 13421 13441 13451 13457 13463 
b_file:13291 13297 13309 13313 13327 13331 13337 13339 13367 13381 13397 13399
13411 13417 13421 13441 13451 13457 13463 
[stefan Thu  7:19:05 1 my_parrot]$ 

/Stefan

Reply via email to