球拍博士、R5RS 和 SRFI [英] Dr Racket, R5RS and SRFI

查看:48
本文介绍了球拍博士、R5RS 和 SRFI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试在 drracket r5rs 语言中使用 foldreduce 等 srfi/1 函数时,我都会得到一个空列表?错误.经过一番研究,我发现这是因为该函数需要一个不可变的列表,但得到了一个可变的列表.我如何在 r5rs 中创建不可变列表,或者这个 srfi/1 的设计是否考虑到了 r5rs?

Whenever I try to use srfi/1 functions like fold and reduce in drracket r5rs language I get an null-list? error. After some research I found that it is due to the fact that the function requires and immutable list but gets a mutable one. How do I create immutable list in r5rs or is this srfi/1 not designed with r5rs in mind?

推荐答案

这基本上是在重申约翰所说的话,但它绝对确实值得一个完整的回答状态.(约翰,如果你逐字复制这个答案,我很乐意删除它......)

This is basically reiterating what John said, but it definitely does merit a full answer status. (John, I'll be happy to delete this if you copy this answer verbatim...)

Racket 的 R5RS 语言的特点是它非常严格地只使用 R5RS 语言,因此除此之外别无他物.(SRFI 也可以为 R5RS 可变对实现,但没有人想出改编的代码.)

The thing about Racket's R5RS language is that it sticks very strictly to just the R5RS language, and therefore comes with nothing beyond that. (SRFIs could be implemented for the R5RS mutable pairs too, but nobody ever came up with the adapted code.)

无论如何,这里的底线是 R5RS 基本上只在那些极少数情况下有用,在这种情况下,您想给自己造成仅使用基本 r5rs 语言编写的痛苦——这意味着您基本上无法做到很多有用的东西.所以特别是如果你想感受一下这门语言,你很可能想要玩转 r5rs 狭隘世界之外的各种东西——为此你应该使用 #lang racket.

In any case, the bottom line here is that R5RS is basically useful only in those rare cases where you want to inflict on yourself the pain of writing using just the basic r5rs language -- which means that you basically can't do much useful things. So especially if you want to get a feel for the language, you'll likely want to play with all kinds of things that go beyond the narrow r5rs world -- and for that you should use #lang racket.

在只是理解语言"方面也更好,您甚至可以将相同的课程应用于其他 Scheme 实现,但要记住它们都有自己的扩展.如果您使用有限的 r5rs 语言,您可能会体验到这种有限语言带来的挫败感,这很容易压倒您在其他情况下可能获得的任何积极体验.

It's also better in terms of "just grokking the language", and you can even apply the same lessons to other Scheme implementations baring in mind that they all come with their own extensions. If you use the limited r5rs language, you'll likely to experience the frustration that comes with such a limited language and this can easily overwhelm any positive experience you might have with it otherwise.

这篇关于球拍博士、R5RS 和 SRFI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆