Error messages use the name reported by object-name. 2014-03-07 13:11 GMT+01:00 Laurent <laurent.ors...@gmail.com>: > Is this really a need? I really wouldn't bother to have >> (object-name empty?) > 'null? > > (I have no strong opinion on the subject though, I'm just wondering if there > is a pratical different too) > > Laurent > > > > On Fri, Mar 7, 2014 at 12:27 PM, Jens Axel Søgaard <jensa...@soegaard.net> > wrote: >> >> The (define (empty? l) (null? l)) is needed due to object-name. >> >> > (object-name null?) >> 'null? >> > (object-name empty?) >> 'empty? >> > (define my-empty? empty?) >> > (object-name my-empty?) >> 'empty? >> >> /Jens Axel >> >> >> 2014-03-07 12:19 GMT+01:00 Ryan Davis <zenspi...@gmail.com>: >> > >> > On Mar 7, 2014, at 2:45, Daniel Carrera <dcarr...@gmail.com> wrote: >> > >> >> Hello, >> >> >> >> Is there any difference between `first` and `car`, or between `last` >> >> and `cdr`, or between `empty? and null?` ? >> >> >> >> I had assumed that these were just synonyms, added by Racket because >> >> they might be more memorable to a student. But apparently Racket doesn't >> >> think they are equal: >> >> >> >> -> (equal? first car) >> >> #f >> >> -> (equal? last cdr) >> >> #f >> >> -> (equal? empty? null?) >> >> #f >> >> >> >> >> >> I suppose that they could be separate functions that happen to do the >> >> same thing, but if so, my next question would be why they aren't just >> >> aliases. As in: >> >> >> >> -> (define myfirst car) >> >> -> (equal? myfirst car) >> > >> > For many/most things in racket, you can bring up the definition for >> > something inside of DrRacket: >> > >> > (define (first x) >> > (if (and (pair? x) (list? x)) >> > (car x) >> > (raise-argument-error 'first "(and/c list? (not/c empty?))" x))) >> > >> > I couldn't for car, so I'm assuming it is considered a primitive. >> > >> > last and cdr aren't synonymous: >> > >> > (define (last l) >> > (if (and (pair? l) (list? l)) >> > (let loop ([l l] [x (cdr l)]) >> > (if (pair? x) >> > (loop x (cdr x)) >> > (car l))) >> > (raise-argument-error 'last "(and/c list? (not/c empty?))" l))) >> > >> > >> > (define (empty? l) (null? l)) >> > >> > null? seems to be a primitive as well. Not sure why they're not direct >> > synonyms in this case. >> > >> > >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users >> >> >> >> -- >> -- >> Jens Axel Søgaard >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > >
-- -- Jens Axel Søgaard ____________________ Racket Users list: http://lists.racket-lang.org/users