fix an issue that was causing memory corruption in the example/Primes.forth

FossilOrigin-Name: 7ea7b110de04a5e330a4ff2dc9bc99414607b4daa8818c945890107ca95ad030
This commit is contained in:
crc 2017-10-23 14:53:44 +00:00
parent 4b537c931b
commit ab1a93a1a8

View file

@ -2,23 +2,23 @@ This is a quick and dirty way to find prime numbers in a set.
````
{{
#2 'last var<n>
#2 'NextPrime var<n>
:extract (s-s)
[ @last dup-pair eq?
[ @NextPrime dup-pair eq?
[ drop-pair TRUE ]
[ mod n:-zero? ] choose ] set:filter ;
---reveal---
:get-primes (s-s)
#2 !last
dup fetch [ extract &last v:inc ] times ;
#2 !NextPrime
dup fetch [ extract &NextPrime v:inc ] times ;
}}
````
And a test:
````
here
#7500 ,
#2 #7502 [ dup , n:inc ] times drop
get-primes [ putn sp ] set:for-each
:create-set (-a)
here #7000 , #2 #7002 [ dup , n:inc ] times drop ;
create-set get-primes [ putn sp ] set:for-each
````