Page 61: the example with the member function. This statement in the book is actually not true: "...the member function still gives the correct answer, even when we search for nil as the member!"
Subject: Page 61: the example with the member function. This statement in the book is actually not true: "...the member function still gives the correct answer, even when we search for nil as the member!"
Subject: Re: Page 61: the example with the member function. This statement in the book is actually not true: "...the member function still gives the correct answer, even when we search for nil as the member!"
Subject: Re: Page 61: the example with the member function. This statement in the book is actually not true: "...the member function still gives the correct answer, even when we search for nil as the member!"
Many thanks for responding. I don't know what I'm doing wrong. When I entered that line, the output was the second of the options, and it prints FALSE (so I guess it is returning FALSE instead of '(nil) ).
I have attached a screenshot (see attached)... am I missing something simple?
Subject: Re: Page 61: the example with the member function. This statement in the book is actually not true: "...the member function still gives the correct answer, even when we search for nil as the member!"
Therefore, nil is not found in the list, and the second of the options
is printed.
In your second example:
(if (member nil '(3 4 1 nil))
'false
'true)
nil is found in '(3 4 1 nil), so member returns the tail, which is
'(nil). This evaluates to true (because it is not nil), and therefore
the first option is returned, which you've specified to be the symbol
'false (which might be what is confusing you!)
On Fri, Aug 24, 2012 at 5:47 PM, Shafique <shafique.ja...@gmail.com> wrote:
> Hello Archie,
> Many thanks for responding. I don't know what I'm doing wrong. When I
> entered that line, the output was the second of the options, and it prints
> FALSE (so I guess it is returning FALSE instead of '(nil) ).
> I have attached a screenshot (see attached)... am I missing something
> simple?
> On Friday, August 24, 2012 6:45:21 PM UTC+5, Archie Maskill wrote:
>> On Fri, Aug 24, 2012 at 2:31 PM, Shafique <shafiqu...@gmail.com> wrote:
>> > (if (member nil '(3 4 1 nil)))
>> > 'nil-is-in-the-list
>> > 'nil-is-not-in-the-list)
>> > The member function will return nil even though nil is in the list (I
>> > tested
>> > this).
>> Are you sure that member is returning nil?
>> For me, in the example you gave, member returns '(nil), which is
>> different from nil.
Subject: Re: Page 61: the example with the member function. This statement in the book is actually not true: "...the member function still gives the correct answer, even when we search for nil as the member!"
> Therefore, nil is not found in the list, and the second of the options > is printed.
> In your second example: > (if (member nil '(3 4 1 nil)) > 'false > 'true)
> nil is found in '(3 4 1 nil), so member returns the tail, which is > '(nil). This evaluates to true (because it is not nil), and therefore > the first option is returned, which you've specified to be the symbol > 'false (which might be what is confusing you!)
> Archie
> On Fri, Aug 24, 2012 at 5:47 PM, Shafique <shafiqu...@gmail.com<javascript:>> > wrote: > > Hello Archie,
> > Many thanks for responding. I don't know what I'm doing wrong. When I > > entered that line, the output was the second of the options, and it > prints > > FALSE (so I guess it is returning FALSE instead of '(nil) ).
> > I have attached a screenshot (see attached)... am I missing something > > simple?
> > On Friday, August 24, 2012 6:45:21 PM UTC+5, Archie Maskill wrote: