Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 当球拍中需要数字时使用文字_List_Integer_Racket_Literals_Illegalargumentexception - Fatal编程技术网

List 当球拍中需要数字时使用文字

List 当球拍中需要数字时使用文字,list,integer,racket,literals,illegalargumentexception,List,Integer,Racket,Literals,Illegalargumentexception,我试着用这个: (vector-set! (vector-ref array (car xy)) (cdr xy) step_count) 其中xy是作为参数传入的类似于“(0)的列表 但我得到了这个错误: vector-set!: contract violation expected: exact-nonnegative-integer? given: '(0) argument position: 2nd other arguments...: '#(0 0 0 0

我试着用这个:

(vector-set! (vector-ref array (car xy)) (cdr xy) step_count)
其中xy是作为参数传入的类似于“(0)的列表

但我得到了这个错误:

vector-set!: contract violation
  expected: exact-nonnegative-integer?
  given: '(0)
  argument position: 2nd
  other arguments...:
   '#(0 0 0 0 0)
   1
(cdr xy)有一个问题,我想我需要将“(0)转换为0,但我在球拍中找不到一个机制可以做到这一点

我知道这样一句话:

(vector-set! (vector-ref array (sub1 (car xy))) (sub1 (cdr xy)) (read))
使用以下工具形成xy时起作用:

(define xy (cons (read) (read)))
有人能给我指出正确的方向吗


感谢阅读。

当您在
列表上使用
cdr
时,它表示“列表的其余部分”。列表的其余部分始终是
列表
,而不是列表中的单个元素

如果需要列表的第二个元素
xy
,则需要使用
cadr

(您也可以使用
second

(define xy (list 1 2 3))
(cdr xy)    ; '(2 3)
(cadr xy)   ;   2
(second xy) ;   2