The definitions for CAR and CDR are identical and they don't make much sense (set the symbol 'car to the value of a function that takes angument xs, which is a function, and applies that to the symbol 'car)
And the definition for CONS is equally opaque.
How would you use those functions, CONS, CAR and CDR?
Since you pretty much nailed the uses of church numerals, monads and the y-combinator, I know you know what you're talking about, it just that Lisp's semantics is confusing me (it has common lisp keyword SETQ but none of its behavior)
If mquander's explanation isn't enough, you might look at it using terms from the OO world: CAR takes a pair object and calls its 'car method.
I thought what you wrote was supposed to be a primitive implementation of the functions.
Imagine encoding the pair ('hello . 'world) into a function. You might say:
(lambda (msg)
(if (eq msg 'car) 'hello 'world))
You could get 'hello by applying that function to the 'car symbol, or 'world by applying it to anything else. Wrapping that in another function lets us generalise to any CAR/CDR. (lambda (car-value cdr-value)
(lambda (msg)
(if (eq msg 'car) car-value cdr-value)))If you evaluate (car (cons 1 2)) and (cdr (cons 1 2)) on paper using substitution, you'll see how it works.
You can take this pretty far. Essentially, you just need 'lambda and application. You could use church numerals for numbers, monads for side effects, the y-combinator for recursion, etc.