[racket] member et al.
On Thu, Nov 11, 2010 at 10:56:17AM -0700, Jay McCarthy wrote:
> On Thu, Nov 11, 2010 at 10:31 AM, Neil Toronto <neil.toronto at gmail.com> wrote:
>
> (define (andmap f l)
> (if (empty? l)
> #t
> (and (f (first l)) (andmap f (rest l)))))
>
> If and has to return a boolean, then it leaves space on the stack to
> check if andmap returns a bool or to convert "truth" to #t. Thus this
> program goes from constant stack space to linear stack space.
Not if the argument to and also has to return a boolean, and the
interpreter knows it. Of course, knowing it is a static type.
-- hendrik