Reputation: 37
I looked around and another answer on stack exchange said I'm wrapping something with parentheses that I shouldn't since that's invoking a value as a function. I can't find where in my cond
that is happening. Here is the erroneous procedure
(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))]
)
)
)
)
The error pops up because I'm trying to stop my procedure from recurring past the null pointer. But now it's giving me the current error. Other places mention it's throwing this error because i'm using () to invoke a function call, but I don't see how in that line It would cause that, isn't it just the format of cond
?
Upvotes: 1
Views: 137
Reputation: 31147
Look right outside the cond:
(lambda (l)(
;; if the car is null, return empty list
(cond
The value returned by cond
is applied as a function due to the (
.
Change it to:
(lambda (l)
;; if the car is null, return empty list
(cond
Upvotes: 3