From ab1a93a1a87f60f84518873373f353a65b581f50 Mon Sep 17 00:00:00 2001 From: crc Date: Mon, 23 Oct 2017 14:53:44 +0000 Subject: [PATCH] fix an issue that was causing memory corruption in the example/Primes.forth FossilOrigin-Name: 7ea7b110de04a5e330a4ff2dc9bc99414607b4daa8818c945890107ca95ad030 --- example/Primes.forth | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/example/Primes.forth b/example/Primes.forth index 04516e7..14d332e 100644 --- a/example/Primes.forth +++ b/example/Primes.forth @@ -2,23 +2,23 @@ This is a quick and dirty way to find prime numbers in a set. ```` {{ - #2 'last var + #2 'NextPrime var :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 ````