"bt" == barney toma <address@hidden> writes:
bt> I receive a stack overflow error when creating a list of 500
bt> entries.
bt> (define (rep n) ;(rep n) ==> (n n-1 n-2 ... 1)
bt> (cond ((= n 0) '())
bt> (t (cons n (rep (- n 1) )))))
bt> (rep 500)
bt> I believe the default stacksize is larger than this. So I'm
bt> wondering if this indicates some abnormal condition such as a
bt> possible hardware problem.
I don't think so, unless I have a hardware problem too. A tail-
recursive procedure will give you a list as long as you wish (but in
ascending order):
(define (rep n ls)
(cond ((= n 0) ls)
(else (rep (- n 1) (cons n ls)))))
(rep 10000 '())
I think by setting the stack limit so low (389) they encourage you to
write tail recursive procedures (correct me if I'm wrong).