我环顾四周,关于堆栈交换的另一个答案说,我用括号括起了一些东西,我不应该这样做,因为那是在调用一个值作为函数。我找不到发生在cond
中的位置。这是错误的过程
(define insert_labels (lambda (l)(
;; if the car is null, return empty list
(cond
;; if the next element is null, append and break
[(null? l) ""]
;; Before it was recurring to the null pointer and adding the car of that to
;; my hash table. This was my attempt to try and stop that but now i'm getting
;; my current error
[(eq? (cdr l) '()) 0]
;; if the car of the list is of type other, append the cadr and recur
[(eq? (what-kind (car l)) 'other) (hash-set! label_hash (car l) (cadr l)) (insert_labels (cdr l))]
;; else, recur
[else (insert_labels (cdr l))]
)
)
)
)
弹出错误,因为我试图阻止我的过程重复通过空指针。但是现在它给了我当前的错误。其他地方提到它会引发此错误,因为我正在使用()来调用函数调用,但我看不出该行的方式会导致该错误,这不仅是cond
的格式吗?
在cond外面看:
(lambda (l)(
;; if the car is null, return empty list
(cond
cond
返回的值由于(
而被用作函数。
将其更改为:
(lambda (l)
;; if the car is null, return empty list
(cond