5 ms·
What does “my other car is a cdr” mean?
- technologia 9y agoPersonally I love the response that Peter gave, especially the revision "my other CAR is a CADR. CDR isn't a CAR at all"
- gm-conspiracy 9y agoCDR is the "input" to CADR and the result is CAR?
- ball_of_lint 9y agoNot 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.
- ambulancechaser 9y agosomeone mentioned it earlier but it's not true that cdr always returns a list, for instance, `(cdr `(1 . 2))`
- kaushalmodi 9y agoIf 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 ..))`.
- dreamcompiler 9y agoTo 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.
- frou_dh 9y agoSmall sticker on a car's rear bumper: "If you can read this then you're my cdr". Same on the next one.
- lispfan01 9y agoCAR and CDR https://en.m.wikipedia.org/wiki/CAR_and_CDR https://en.m.wikipedia.org/wiki/CAR_and_CDR
- KirinDave 9y agoOooohhh I had forgotten this. For once, this website made me smile. My it's sad how Common Lisp has faded away in the last 10 years. It had a great community.
- teolandon 9y agoIt's very sad how most new programmers aren't even versed in any functional languages, or even know what they are. Everyone learns imperative because they're so much easier and intuitive initially. Well, that and... almost everyone in software development now uses some kind of imperative language, or some .js framework. Granted, there still are big projects in Common Lisp today, Emacs still going strong, lots of travel websites are also in Lisp. But yeah, not much motivation for new programmers to learn that type of language.
- graphitezepp 9y agoI keep meaning to learn some functional programming just for learning and introduction to new ideas, but I basically forget they exist typically. Never see them referenced in the "business" side, only ever in techie discussion. Not much motivation indeed.
- currymj 9y agoI don't agree with this at all! More or less every mainstream language has adopted first-class functions to the extent that they can. JS has always had them. C++, C#, Java have all added them; Python and Ruby have had them for a while now. Standard functional programming constructs like map, filter, and reduce are now extremely familiar, whereas not too long ago they would have required a tutorial and explanation. And just as imperative languages have adopted functional features, functional languages are growing more popular. Even if you just limit yourself to Lisps, Clojure is used widely. There are probably many more Lisp programmers now than there were 5 or 10 years ago, thanks to Clojure's adoption. Branching out a bit, Scala is also very popular. That's not even to consider hipper, trendier things like Elm, or the increased popularity and visibility of Haskell.
- 9y ago
- sf_rob 9y agoReminds me of my Lisp professor's terrible joke, "Today we're going to learn about defining functions because that's where de fun's at"...
- plafl 9y agoRelated: http://www.poppyfields.net/filks/00103.html http://www.poppyfields.net/filks/00103.html
- lathiat 9y agoHere I was thinking it was some kind of joke about you wouldn't download a car.. never learnt Lisp!
- jeremy0x4a 9y agoI just came across a reference to this while attempting to establish my Keybase proof for Hacker News and now I've fallen down a rabbit hole.
- diegoprzl 9y agoMess with the car die like the cdr.