<div dir="ltr">good point, thanks.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Mar 7, 2014 at 1:18 PM, Jens Axel Søgaard <span dir="ltr"><<a href="mailto:jensaxel@soegaard.net" target="_blank">jensaxel@soegaard.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Error messages use the name reported by object-name.<br>
<br>
2014-03-07 13:11 GMT+01:00 Laurent <<a href="mailto:laurent.orseau@gmail.com">laurent.orseau@gmail.com</a>>:<br>
<div class="HOEnZb"><div class="h5">> Is this really a need? I really wouldn't bother to have<br>
>> (object-name empty?)<br>
> 'null?<br>
><br>
> (I have no strong opinion on the subject though, I'm just wondering if there<br>
> is a pratical different too)<br>
><br>
> Laurent<br>
><br>
><br>
><br>
> On Fri, Mar 7, 2014 at 12:27 PM, Jens Axel Søgaard <<a href="mailto:jensaxel@soegaard.net">jensaxel@soegaard.net</a>><br>
> wrote:<br>
>><br>
>> The (define (empty? l) (null? l)) is needed due to object-name.<br>
>><br>
>> > (object-name null?)<br>
>> 'null?<br>
>> > (object-name empty?)<br>
>> 'empty?<br>
>> > (define my-empty? empty?)<br>
>> > (object-name my-empty?)<br>
>> 'empty?<br>
>><br>
>> /Jens Axel<br>
>><br>
>><br>
>> 2014-03-07 12:19 GMT+01:00 Ryan Davis <<a href="mailto:zenspider@gmail.com">zenspider@gmail.com</a>>:<br>
>> ><br>
>> > On Mar 7, 2014, at 2:45, Daniel Carrera <<a href="mailto:dcarrera@gmail.com">dcarrera@gmail.com</a>> wrote:<br>
>> ><br>
>> >> Hello,<br>
>> >><br>
>> >> Is there any difference between `first` and `car`, or between `last`<br>
>> >> and `cdr`, or between `empty? and null?` ?<br>
>> >><br>
>> >> I had assumed that these were just synonyms, added by Racket because<br>
>> >> they might be more memorable to a student. But apparently Racket doesn't<br>
>> >> think they are equal:<br>
>> >><br>
>> >> -> (equal? first car)<br>
>> >> #f<br>
>> >> -> (equal? last cdr)<br>
>> >> #f<br>
>> >> -> (equal? empty? null?)<br>
>> >> #f<br>
>> >><br>
>> >><br>
>> >> I suppose that they could be separate functions that happen to do the<br>
>> >> same thing, but if so, my next question would be why they aren't just<br>
>> >> aliases. As in:<br>
>> >><br>
>> >> -> (define myfirst car)<br>
>> >> -> (equal? myfirst car)<br>
>> ><br>
>> > For many/most things in racket, you can bring up the definition for<br>
>> > something inside of DrRacket:<br>
>> ><br>
>> > (define (first x)<br>
>> > (if (and (pair? x) (list? x))<br>
>> > (car x)<br>
>> > (raise-argument-error 'first "(and/c list? (not/c empty?))" x)))<br>
>> ><br>
>> > I couldn't for car, so I'm assuming it is considered a primitive.<br>
>> ><br>
>> > last and cdr aren't synonymous:<br>
>> ><br>
>> > (define (last l)<br>
>> > (if (and (pair? l) (list? l))<br>
>> > (let loop ([l l] [x (cdr l)])<br>
>> > (if (pair? x)<br>
>> > (loop x (cdr x))<br>
>> > (car l)))<br>
>> > (raise-argument-error 'last "(and/c list? (not/c empty?))" l)))<br>
>> ><br>
>> ><br>
>> > (define (empty? l) (null? l))<br>
>> ><br>
>> > null? seems to be a primitive as well. Not sure why they're not direct<br>
>> > synonyms in this case.<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>
>><br>
>> --<br>
>> --<br>
>> Jens Axel Søgaard<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>
<br>
<br>
<br>
--<br>
--<br>
Jens Axel Søgaard<br>
</div></div></blockquote></div><br></div>