Newsgroups: comp.lang.scheme
From: Barry Margolin <bar...@alum.mit.edu>
Date: Tue, 29 May 2012 09:30:07 -0400
Local: Tues, May 29 2012 9:30 am
Subject: Re: problem with lat? (TLS 4ed)
In article <100b32e5-3a4e-42c6-8795-7308e19e872e@googlegroups.com>,
colin howarth <co...@howarth.de> wrote: > Hi, I'm just starting out with Scheme (and Lisp) and am going through The In a recursive algorithm, you have to handle the case where the > Little Schemer. > I'm confused, right at the beginning and wanted to ask, since this seems > lat? is defined in the book as
> (define lat?
> This terminates with #t when l has become the empty list (and all its > However, it also evaluates to #t if given the empty list to start with.
> But atom? is defined as
> (define atom?
> which says that x must not be null.
> My attempt at lat? was
> (define lat?
> which reads as "the first element is an atom and the rest is null, or a list recursion bottoms out *before* doing the non-terminal processes. You're doing them in the wrong order. > [I've done a couple of days of Lisp where (car ()) => nil. In Scheme I don't You can type it as '().
> even know how to *type* an empty list yet, so I'm using (cdr '(a)) or (lambda > () ())] > So. If you've got this far, I suppose the question is should lat? return #t The following should be true for any l1 and l2:
> for an empty list? (eqv? (lat? (append l1 l2))
What if l1 or l2 is the empty list, how can you ensure the tautology?
This type of equation is how you generally figure out how to handle -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||