1
votes

I'm trying to understand the relations between pair, cons, dotted tuples and proper list in PLT-Scheme 372. The detailed context of my question is as follows:

After reading some textbook and doing trial-and-error, I have got the following understanding and intuitive ideas (I may be wrong...):

  1. all lists are pairs, e.g.:

    (pair? (list 'a 'b 'c)) => #t

  2. all conses are pairs, e.g.:

    (pair? (cons 'a (cons 'b 'c))) => #t

  3. some dot-separated tuples are pairs, e.g.:

    (pair? '(a . b)) => #t
    (pair? '(a . b . c)) => #t in Standard R5RS it's not legal syntax.

Then I bumped into this problem: Why does '(a . b . c) evaluate to (b a c)? Where can I find a complete usage manual of dot?

'(a . b)                => (a . b)   
'(a . b . c)            => (b a c)
'(a . b . c . d)        => illegal use of `.'
'(cons 'a (cons 'b 'c)) => (a b . c)
1

1 Answers

5
votes

For Racket (PLT), there is a good description here.

Regarding the syntax (a . b . c) look at the bottom of the page, it's a Racket-specific reader extension designed to express typical tests like (< 1 2) as (1 . < . 2).