Tagged a release
This commit is contained in:
		
							parent
							
								
									1cd5e4edaa
								
							
						
					
					
						commit
						5d07594f53
					
				
					 1 changed files with 13 additions and 4 deletions
				
			
		
							
								
								
									
										17
									
								
								example.scm
									
										
									
									
									
								
							
							
						
						
									
										17
									
								
								example.scm
									
										
									
									
									
								
							|  | @ -1,9 +1,18 @@ | ||||||
| (load "goof.scm") | (import (goof)) | ||||||
| 
 |  | ||||||
| (define (erathostenes n) | (define (erathostenes n) | ||||||
|   (define vec (make-vector n #t)) |   (define vec (make-vector n #t)) | ||||||
|   (loop/list ((:for i (up-from 2 (to n))) |   (loop ((:for i (up-from 2 (:to n))) | ||||||
|  | 	 (:when (vector-ref vec i)) | ||||||
|  | 	 (:acc lst (listing i)) | ||||||
|  | 	 (:for j (up-from (* 3 i) (:to n) (:by (* i 2))))) | ||||||
|  |     => lst | ||||||
|  |     (vector-set! vec j #f))) | ||||||
|  | 
 | ||||||
|  | (define (erathostenes2 n) | ||||||
|  |   (define vec (make-vector n #t)) | ||||||
|  |   (loop/list ((:for i (up-from 2 (:to n))) | ||||||
|               (:when (vector-ref vec i))) |               (:when (vector-ref vec i))) | ||||||
|     (loop ((:for j (up-from (* 2 i) (to n) (by i)))) |     ;; Here we set all multiples of i to #f | ||||||
|  |     (loop ((:for j (up-from (* 3 i) (:to n) (:by (* i 2))))) | ||||||
|       (vector-set! vec j #f)) |       (vector-set! vec j #f)) | ||||||
|     i)) |     i)) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Linus
						Linus