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