News for hackers. Stuff that matters.
Re:What does “my other car is a cdr” mean? by technologia on Thursday May 25, 2017 @09:15AM (#14417059)
Personally I love the response that Peter gave, especially the revision "my other CAR is a CADR. CDR isn't a CAR at all"
Re:What does “my other car is a cdr” mean? by dreamcompiler on Thursday May 25, 2017 @11:12AM (#14417800)
To me the original makes more sense. A cons cell is a 2-tuple. CAR retrieves the first element; CDR retrieves the "other" one. The fact that CARs are usually atoms and CDRs are usually lists is a convention, not a rule. You can easily put an atom in the CDR of a cons (this is called a dotted pair) and you can easily put a list in the CAR.
Re:What does “my other car is a cdr” mean? by gm-conspiracy on Thursday May 25, 2017 @09:24AM (#14417099)
CDR is the "input" to CADR and the result is CAR?
Re:What does “my other car is a cdr” mean? by kaushalmodi on Thursday May 25, 2017 @09:49AM (#14417252)
If you have a list `(Odyssey Model-S)`, `car` will be `Odyssey`, `cdr` will be a list `(Model-S)`. You yet need to do a `car` on that.. So `(car (cdr ..))` will give you `Model-S`. `(cadr ..)` is short for `(car (cdr ..))`.
Re:What does “my other car is a cdr” mean? by ball_of_lint on Thursday May 25, 2017 @09:46AM (#14417226)
Not exactly, cadr is what you would get if you called CDR on a list, then car on the result of that. Lisp has several of these types of chains.

Since cdr always returns a list, to get a single item you would need to call car on it, therefore cadr.

Re:What does “my other car is a cdr” mean? by ambulancechaser on Thursday May 25, 2017 @11:58AM (#14418095)
someone mentioned it earlier but it's not true that cdr always returns a list, for instance, `(cdr `(1 . 2))`