arc3.2语言sort的时候报错:(sort < `(2 9 3 7 5 1)) 需要写成这种:(sort > (pair (list 3 2)))

arc语言sort的时候报错:(sort < '(2 9 3 7 5 1))

复制代码
arc> (sort < '(2 9 3 7 5 1))
Error: "set-car!: expected argument of type <pair>; given: 9609216"
arc> (sort `< `(2 9 3 ))
Error: "Function call on inappropriate object '< '(3 9)"
arc> (sort `(2 9 3))
Error: " sort: arity mismatch;\n the expected number of arguments does not match the given number\n  expected: 2\n  given: 1"
arc> (sort `> `(2 9))
Error: "Function call on inappropriate object '> '(9 2)"
arc> (sort < (list 2 9 3 7 5 1))
Error: "set-car!: expected argument of type <pair>; given: 9551872"
arc> (= sortlist (list 2 9 3 7 5 1))
(2 9 3 7 5 1)
arc> sortlist
(2 9 3 7 5 1)
arc> (sort < sortlist)
Error: "set-car!: expected argument of type <pair>; given: 14000128"

怎么办呢?

搞不明白

最后发现需要这样写:

复制代码
arc> (sort > (pair (list 3 2)))
((3 2))
arc> (sort < (pair (list 2 3)))
((2 3))

也就是需要使用pair 数对,且只能是两个数?

也就是Arc3.2版本的sort是跟以前不一样的....

是更纯粹的,只支持一对数值的pair类型的数据进行排序。

而以前的版本是可以支持list排序的。也就是这种

复制代码
(= nums (list 5 2 8 1 4))
(sort < nums)

对了,list是可以改变的吗? 是不是因此新版本的list就不支持sort了?

相关推荐
Wenweno0o1 天前
0基础Go语言Eino框架智能体实战-chatModel
开发语言·后端·golang
chenjingming6661 天前
jmeter线程组设置以及串行和并行设置
java·开发语言·jmeter
cch89181 天前
Python主流框架全解析
开发语言·python
不爱吃炸鸡柳1 天前
C++ STL list 超详细解析:从接口使用到模拟实现
开发语言·c++·list
十五年专注C++开发1 天前
RTTR: 一款MIT 协议开源的 C++ 运行时反射库
开发语言·c++·反射
Momentary_SixthSense1 天前
设计模式之工厂模式
java·开发语言·设计模式
‎ദ്ദിᵔ.˛.ᵔ₎1 天前
STL 栈 队列
开发语言·c++
勿忘,瞬间1 天前
数据结构—顺序表
java·开发语言
张張4081 天前
(域格)环境搭建和编译
c语言·开发语言·python·ai
weixin_423533991 天前
【Windows11离线安装anaconda、python、vscode】
开发语言·vscode·python