“我的另一辆车是 cdr” 是什么意思?意思是?

发布于 2024-08-13 08:46:41 字数 91 浏览 8 评论 0原文

有精通 lisp 的人能给我解释一下这个笑话吗? 我读过一些关于函数式编程语言的书,知道 CAR/CDR 的意思是地址/减量寄存器的内容,但我仍然不太明白其中的幽默。

Can anyone well versed in lisp explain this joke to me?
I've done some reading on functional programming languages and know that CAR/CDR mean Contents of Address/Decrement Register but I still don't really understand the humour.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

晨与橙与城 2024-08-20 08:46:41

在 Lisp 中,链表元素称为 CONS。它是一个包含两个元素的数据结构,由于历史原因称为 CAR 和 CDR。 (一些 Common Lisp 程序员更喜欢使用 FIRST 和 REST 函数来引用它们,而其他人则喜欢 CAR 和 CDR,因为它们非常适合预组合版本,例如 (CADR x) eq (CAR (CDR x))。

这个笑话是模仿您有时在破旧的旧车上看到的保险杠贴纸,上面写着“我的另一辆车是保时捷/宝马/等等。

” schema/msg/7e19acdc7df6c5aa" rel="noreferrer">对这个笑话的回应一直是“我的另一个 CAR 是 CADR,根本不是 CAR。”

In Lisp, a linked list element is called a CONS. It is a data structure with two elements, called the CAR and the CDR for historical reasons. (Some Common Lisp programmers prefer to refer to them using the FIRST and REST functions, while others like CAR and CDR because they fit well with the precomposed versions such as (CADR x) ≡ (CAR (CDR x)).

The joke is a parody of the bumper stickers you sometimes see on beat-up old cars saying "My other car is a Porsche/BMW/etc."

My response to this joke has always been "My other CAR is a CADR. CDR isn't a CAR at all."

半夏半凉 2024-08-20 08:46:41

是的,绝对是一个极客笑话。

这些名称来自 IBM 704,但这不是玩笑。

这个笑话是“我的另一辆车是___”的(糟糕)双关语。但笑话是关于递归的。

当你在 lisp 中循环/操作/选择/调用/更多时,你使用 car (列表中的第一个元素)和 cdr (列表的其余元素)的组合来处理函数。

所以你有一辆车,但你的另一辆车是你的 cdr,因为你总是可以从 cdr 获得一辆车,因为 cdr 总是(递归)更多元素。得到它?笑了吗?

你可能需要学习 lisp 才能真正笑起来,或者不笑。当然,到那时,你可能会发现自己无缘无故地咯咯笑,因为:

Lisp 让你发疯。

Yes, definitely a geek joke.

The names come from the IBM 704, but that's not the joke.

The joke is (bad) pun on "my other car is a ___." But the in-joke is about recursion.

When you loop/manipulate/select/invoke/more in lisp you use a combination of car (the first element in the list) and cdr (the rest of the list) to juggle functions.

So you've got a car, but your other car is your cdr because you can always get a car from a cdr since the cdr is always (in recursion) more elements. Get it? Laugh yet?

You'll probably have to learn lisp to actually chuckle a bit, or not. Of course, by then, you'll probably find yourself chuckling randomly for no apparent reason because:

Lisp makes you loopy.

注定孤独终老 2024-08-20 08:46:41

//来自Scheme
Scheme 的数据结构很少,其中一个是元组:'(first . secondary)。在本例中,car 是第一个元素,cdr 是第二个元素。此构造可以扩展以创建列表、树和其他结构。
这个笑话不太好笑。

//Coming from Scheme
Scheme has very few data structures, one of them is a tuple: '(first . second). In this case, car is the first element, and cdr is the second. This construct can be extended to create lists, trees, and other structures.
The joke isn't very funny.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文