[英]Sort with R5RS scheme in DrRacket
I'm learning scheme using DrRacket version 7.0. 我正在学习使用DrRacket 7.0版的方案。
I have copied, and modified, the following procedure from this SO answer . 我已经从该SO答案复制并修改了以下过程。
#lang racket
(define sort-asc-by-second
(lambda (lst)
(sort lst
(lambda (x y) (< (cdr x) (cdr y))))))
And it works perfectly. 而且效果很好。
Now I have change the #lang racket
instruction with this one #lang r5rs
. 现在,我用#lang r5rs
更改了#lang racket
说明。
And DrRacket complains with the following error: DrRacket抱怨以下错误:
sort: unbound identifier in: sort 排序:绑定标识符:排序
Do I forget to add something to DrRacket (libraries, modules, etc.)? 我是否忘记在DrRacket中添加某些内容(库,模块等)? Or maybe sort
is not available in R5RS. 或者也许R5RS中没有sort
。
According to the R5RS report there is no such thing as sort
. 按照R5RS报告有没有这样的东西sort
。 You may fetch the reference implementation for sort
from SRFI-95 Sorting and merging . 您可以从SRFI-95排序和合并中获取用于sort
的参考实现。 It's not 100% compatible with the #lang racket
one. 它与#lang racket
不是100%兼容的。 R5RS doesn't have libraries so the portable way would be to load
it or inline it. R5RS没有库,因此可移植的方式是load
或内联它。
R6RS has superseded R5RS and it has list-sort
in its standard library. R6RS取代了R5RS,并且在其标准库中具有list-sort
。
R7RS-Large, which is not yet fully ratified, uses SRFI-132 as it sorting library (scheme sort)
which also has list-stable-sort
which is the same as the R6RS list-sort
. R7RS-大,这还没有完全批准,使用SRFI-132 ,因为它分拣库(scheme sort)
也具有list-stable-sort
是一样的R6RS list-sort
。
In Racket you can mix and match libraries from all the languages it supports, but it does not work for lists that are implemented differently and it is a lock in. Being dependent on a different languages library means you cannot run the code with other implementations, like Ikarus and Chez. 在Racket中,您可以混合和匹配其支持的所有语言的库,但是它不适用于以不同方式实现的列表,并且是锁定的。依赖于其他语言的库意味着您无法在其他实现中运行代码,像伊卡洛斯(Ikarus)和切斯(Chez)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.