I always thought cons, car, and cdr were so low-level that they had to be builtins. However, interestingly enough, SICP shows how they could be implemented using a closure:
(define (my-cons a b)It's kind of silly, but it also works in Python:
(cond ((= pick 1) a)
((= pick 2) b))))
(define (my-car x) (x 1))
(define (my-cdr x) (x 2))
def cons(a, b):Neat!
if pick == 1:
elif pick == 2:
It's easy to see how to extend this in Scheme to have "objects" with any number of memebers, although I'm sure it's not very efficient.
By the way, I really like DrScheme. It's relatively modern and very friendly.