I'm now using racket to build the function that return the list of animal's name corresponding to the given animal list. But there comes a problem.
(define (name-pets l)
(cond
[(eq? "dog" first(l)) (append 'happy (name-pets (rest (l))))]
[(eq? "cat" first(l)) (append 'smart (name-pets (rest (l))))]
[(eq? "pig" first(l)) (append 'pinky (name-pets (rest (l))))]
[else (append 'unnamed (name-pets (rest (l))))]))
(name-pets (list "pig" "cat" "dog" "dolphin"))
And when I ran the code,
application: not a procedure; expected a procedure that can be applied to arguments
given: '("pig" "cat" "dog" "dolphin")
arguments...: [none]
What is the problem?