I am a new student of Scheme / Racket, so please excuse any gross syntax errors.
Today in the class it appeared that the list of schemes '(a, b, c)
must be invalid, but when we started it, it returned:
>'(a . b . c) (bac)
It makes no sense. Afaik, the translator must create a cons cell with the car 'a and cdr' b, and c must be invalid. However, the translator is doing something really strange here. This works with C # lang schema, #lang racket and others. We use DrRacket as an interpreter.
Interesting that
>'(a . b . c . d)
throws an exception and dies.
I am very curious and would like to understand this, since I am new to the language. Google was very useless (perhaps because the search terms are ambiguous) Thank you!
EDIT: This may be because '(a . b . c)
interpreted using b as an infix operator. For example: >(4 . + . 6)
returns 10. Maybe the interpreter uses b as an operator? those. (bac)
, like (+ 4 6)
, infix-wise.
The experience says:
>(define b +) >(define a 4) >(define c 6) >(a . b . c) 10
So, I think this solves the problem, but I still do not fully understand the use of ".". operator in this case. I think we have solved this, but a deeper understanding will be appreciated!
source share