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了?

相关推荐
1104.北光c°1 小时前
滑动窗口HotKey探测机制:让你的缓存TTL更智能
java·开发语言·笔记·程序人生·算法·滑动窗口·hotkey
for_ever_love__2 小时前
Objective-C学习 NSSet 和 NSMutableSet 功能详解
开发语言·学习·ios·objective-c
似水明俊德8 小时前
02-C#.Net-反射-面试题
开发语言·面试·职场和发展·c#·.net
Thera7779 小时前
C++ 高性能时间轮定时器:从单例设计到 Linux timerfd 深度优化
linux·开发语言·c++
炘爚9 小时前
C语言(文件操作)
c语言·开发语言
阿蒙Amon9 小时前
C#常用类库-详解SerialPort
开发语言·c#
凸头10 小时前
CompletableFuture 与 Future 对比与实战示例
java·开发语言
wuqingshun31415910 小时前
线程安全需要保证几个基本特征
java·开发语言·jvm
Moksha26210 小时前
5G、VoNR基本概念
开发语言·5g·php
jzlhll12310 小时前
kotlin Flow first() last()总结
开发语言·前端·kotlin