[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: proper tail recusion for `or'
>Please, correct me if I am wrong. By using the stepper, it seems that
>DrScheme do not handle tail recursion properly for `or'. Is this a bug?
>
>Here is an example:
>
> (define (list-or l)
> (if (null? l)
> #t
> (or (car l) (list-or (cdr l)))))
>
> (list-or (list #f #f #f #f #f #f #t))
>
>Thank you.
>MM
If I understand you correctly, you're surprised by the fact that,
say, (or #f M) reduces to (or M), rather than directly to M. This is
because the beginner and intermediate languages require that all
arguments to or be booleans. If M was tail w.r.t the expression (or
#f M), this check would not be possible.
Does this answer your question?
john