Ah. Thanks. Please disregard the final question on my last email. You just
answered it.


On 7 March 2014 12:27, 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
>



-- 
When an engineer says that something can't be done, it's a code phrase that
means it's not fun to do.
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to