<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 11.00.9600.17496"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=666432019-03012015><FONT color=#0000ff
size=2 face=Arial>The addition "at least" does it.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=666432019-03012015><FONT color=#0000ff
size=2 face=Arial>Thanks, Jos</FONT></SPAN></DIV><BR>
<DIV lang=en-us class=OutlookMessageHeader dir=ltr align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> Carl Eastlund
[mailto:carl.eastlund@gmail.com] <BR><B>Sent:</B> 03 January 2015
20:17<BR><B>To:</B> Jos Koot<BR><B>Cc:</B> Matthias Felleisen; Frank Weytjens;
users Users<BR><B>Subject:</B> Re: [racket] Little Schemer,
lat?<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr>
<DIV>
<DIV>
<DIV>Because all-true and all-false are both all-something, they are both
written (and), not (or). If you want something corresponding to (or), you
need at-least-one-true or at-least-one-false. In general, all-true is the
negation of at-least-one-false, and all-false is the negation of
at-least-one-true.<BR><BR>On Sat, Jan 3, 2015 at 2:06 PM, Jos Koot <SPAN
dir=ltr><<A href="mailto:jos.koot@gmail.com"
target=_blank>jos.koot@gmail.com</A>></SPAN> wrote:<BR></DIV>
<DIV class=gmail_extra>
<DIV class=gmail_quote>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><SPAN>Matthias,
you write:<BR><BR> all-true is the same as
cannot-find-a-false-on-the-list.<BR><BR></SPAN>Then I take an
inverse:<BR><BR> all-false is the same as
cannot-find-a-true-on-the-list.<BR><BR>But we have (in Racket):<BR><BR>(and)
-> #t<BR>(or) -> #f<BR><BR>Something is wrong with the inversion. But
what?<BR><BR>Happy new year to all, Jos<BR>
<DIV class=HOEnZb>
<DIV class=h5><BR>-----Original Message-----<BR>From: users [mailto:<A
href="mailto:users-bounces@racket-lang.org">users-bounces@racket-lang.org</A>]
On Behalf Of Matthias<BR>Felleisen<BR>Sent: 03 January 2015 03:12<BR>To: Frank
Weytjens<BR>Cc: users Users<BR>Subject: Re: [racket] Little Schemer,
lat?<BR><BR><BR>Frank, happy new year. It's good to hear from people like you
because TLS is<BR>for you.<BR><BR>Now I'd like to say that I am unbelievably
unhappy about Chapter 2 but I<BR>could not convince Dan to change the book
that much. Let's look at lists in<BR>the "How to Design Programs" way, the TLS
for adults if you so wish. Here is<BR>the definition:<BR><BR>A LAT is
either<BR> -- the empty list<BR>or<BR> -- a LAT l extended with one
ATOM.<BR><BR>And we don't care what an ATOM is.<BR><BR>This definition is
unusual because it refers to itself. You haven't seen<BR>such definitions in
your high school courses, and it's best to make sure<BR>this definition
generates some LATs (whatever those are).<BR><BR>* Clearly one thing is a
LAT. T<BR>- he empty list.<BR><BR>* Now suppose we take ATOM1 (whatever
atoms are) and extend the empty list<BR>with ATOM1.<BR>- What do we
get?<BR><BR>* Yes, we get a different LAT.<BR>- Should we give it a
name?<BR><BR>* Sure, what would you like to call it?<BR>- LAT1.<BR><BR>* Great
name. What do you think happens if we extend LAT1 with ATOM2?<BR>- Then we get
LAT2, which is like LAT1 but extended with ATOM2.<BR><BR>And so on. But the
key is, we started by simply defining the empty list to<BR>be a LAT. Note how
we also don't need any "Scheme" or "Racket" things to<BR>express the ideas.
Plain English and an agreement to treat 'extend with' and<BR>'the empty list"
as special phrases.<BR><BR>Time to look the second aspect of your question.
Here is a definition for<BR>LOB:<BR><BR>A LOB is either<BR> -- the empty
list<BR>or<BR> -- a LOB extended with one Boolean.<BR>A Boolean is either
#t or #f.<BR><BR>* Are these LOBs?<BR> the empty list<BR> the
empty list extended with #f<BR> the empty list extended with #f extended
with #t<BR>- Yes they are.<BR><BR>* Are all Booleans on this list #t<BR>
the empty list extended with #t extended with #t<BR>- They sure
are.<BR><BR>* Are all Booleans on this list #t<BR> the empty list
extended with #t<BR>- Still.<BR><BR>* Are all Booleans on this list
#t<BR> the empty list<BR>- It all depends on what "are" means.
[Famous quote. Who said that?]<BR><BR>* How many options do we have?<BR>- Two:
The answer is either true or false.<BR><BR>* How do you define the function
for answer 1 [true]<BR>- Easy<BR>(define (all-true?-1 lob)<BR>
(cond<BR> [(null? lob) #t] ;; by definition, right?<BR>
[else (and (true? (car lob)) (all-true?-1 (cdr lob)))])) ;; <---
this is<BR>now functions should be defined<BR><BR>* What about answer 2
[false]?<BR>- Here is a start:<BR>(define (all-true?-2 lob)<BR>
(cond<BR> [(null? lob) #f] ;; by definition, right?<BR>
[else ...]))<BR><BR>* This function works for the empty list but how
about lists with one or two<BR>or three ... Booleans?<BR>- For all those,
all-true?-1 gives the correct answer.<BR>(define (all-true?-2 lob)<BR>
(cond<BR> [(null? lob) #f] ;; by definition, right?<BR>
[else (all-true?-1 lob)]))<BR><BR>* How come?<BR>- Because all-true?-2
makes sure that all-true?-1 never sees the empty list.<BR><BR><BR>* But
doesn't all-true?-1 look for the empty list?<BR>- Yes, but only after it has
seen at least one Boolean.<BR><BR>* Which answer is simpler, elegant,
satisfying?<BR>- The first one. It's a two-line function and it's easily
explained.<BR><BR>* So what is the better choice?<BR>- It's better to say that
all Booleans on the empty list are true, even<BR>though there aren't
any.<BR><BR>* Is this weird?<BR>- A little bit but it makes everything
easy.<BR><BR>* So let's use this convention from now on.<BR>-
Good.<BR><BR>That's one explanation for considering it correct to say that the
empty list<BR>contains only #t Booleans. Another one:<BR><BR> all-true
is the same as cannot-find-a-false-on-the-list.<BR><BR>Can you deal with this
explanation? -- Matthias<BR><BR><BR><BR><BR><BR><BR><BR>On Jan 2, 2015, at
5:58 PM, Frank Weytjens wrote:<BR><BR>> Happy new year
Racketeers,<BR>><BR>> The Little Schemer is my favorite book.<BR>> I
have a kind of Sisyphus relationship with it.<BR>> In the preface they
advice to not read it, in less then 3 times.<BR>> The jokers! It's more
then 3 years I read this book, from time to time.<BR>> Hoping to get
further and further, each time.<BR>> I enjoy to start over and over,
without completely understanding it.<BR>> Like if: once it 's completely
understood, there is no more interesting<BR>stuff on earth.<BR>> This time
i got stuck much earlier, then normal, extremely early.<BR>><BR>>
(define lat?<BR>> (lambda (l)<BR>>
(cond<BR>>
((null? l) #t)<BR>>
((atom? (car l)) (lat? (cdr l)))<BR>>
(else #f))))<BR>><BR>> An empty list is a list, but
is it a lat ?<BR>> If you give an empty list as argument to the
lat?-function, the answer<BR>> is yes. But an atom must be a string of
characters or numbers, or even<BR>> one character, or a combination of
special characters as long as it is<BR>> not an ( or an ). The empty list
contains no characters at all, so it<BR>> can not be a list of atoms. It
would be OK, if you recur at least<BR>> once. But when you feed an empty
list, this is not the case. Then the<BR>> answer of (null? l) should be
#f<BR>><BR>> Rewriting the function that way, would never give #t as
answer<BR>><BR>> (define lat?<BR>> (lambda
(l)<BR>> (cond<BR>>
((null? l) #f)<BR>>
((atom? (car l)) (lat? (cdr l)))<BR>>
(else #f))))<BR>><BR>><BR>> So an empty
list has to be a lat, and it is not.<BR>> Or is it? Then an empty list can
be anything.<BR>><BR>><BR>> Thanks,<BR>><BR>> Frank<BR>>
____________________<BR>> Racket Users list:<BR>> <A
href="http://lists.racket-lang.org/users"
target=_blank>http://lists.racket-lang.org/users</A><BR><BR><BR>____________________<BR>
Racket Users list:<BR> <A href="http://lists.racket-lang.org/users"
target=_blank>http://lists.racket-lang.org/users</A><BR><BR>____________________<BR>
Racket Users list:<BR> <A href="http://lists.racket-lang.org/users"
target=_blank>http://lists.racket-lang.org/users</A><BR><BR></DIV></DIV></BLOCKQUOTE></DIV><BR></DIV></DIV></DIV></DIV></BODY></HTML>