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