your cond
does not have a default case. So when (modulo n int)
is not zero your get a undefined value. Add one like this:
(cond (predicat-expression consequent-expression)
(predicat-expression2 consequent-expression2)
(else alternative-expression))
Since you only have one consequent expression you could do this with if
(if predicate-expression
consequent-expression
alternative-expression)
Now if you don't any elements when predicate is not true then yuu should not cons anything when it's false but continue to the next true value:
(define gen_item
(lambda (n int)
(if (= 0 (modulo n int))
(cons n (lambda () (gen_item (+ n 1) int)))
(gen_item (+ n 1) int))))