With zero removal and the "glorious iterator" in action ...
-----------------
(define divisor?
(lambda (p q)
(let (( x (/ p q)))
(if (= x (floor x)) 1 0 ))))
(define more-divisorsx
(lambda ( i x nr)
(if (or (> i (/ x 2)) (> nr 0 ) ) nr
(more-divisorsx (+ i 1) x (+ nr (divisor? x i))))))
(define more-divisors
(lambda (x)
(more-divisorsx 2 x 0)))
(define prime?
(lambda (x)
(if (= (more-divisors x) 0 ) x 0 )))
(define make-listx
(lambda (i x L)
(if (= i x) L
(make-listx (+ i 1) x (cons i L)))))
(define make-list
(lambda (x)
(reverse (make-listx 2 x '() ))))
(define range
(lambda (x)
(reverse (make-listx 0 x '() ))))
(define sq (make-list 200))
(define iterate
(lambda (op it)
(map (eval op) (range it))
T ))
(define filter-zeroesx
(lambda (L M)
(if (= (length L) 0) M
(if (> (car L) 0 ) (filter-zeroesx (cdr L) (cons (car L) M))
(filter-zeroesx (cdr L) M )))))
(define filter-zeroes
(lambda (L)
(filter-zeroesx L '() )))
(define main
(lambda ()
(iterate 'newline 10)
(newline)
(print 'SBLisp ) (newline)
(print '------ ) (newline) (newline)
(print 'List= )
(print sq)
(newline)
(newline)
(print '"Filtering primes by mapping")
(newline)
(let (( res (map prime? sq)))
(print res)
(iterate 'newline 3)
(print '"Removing the zeroes") (newline)
(print (reverse (filter-zeroes res)))
(newline)
(print '....finished )
(print '..... )
)))
(main)
-------------------------------
best , Rob ... the (reverse .. ) because it are all FILO operations ... first in - last out
addendum -- added 006 which does proper printing too.
Is it auto-GC , or do I have to code it
?
.