0

Working on an assignment right now (racket) and came across this problem.

> (define a '(even?))
> a
(even?)
> (first a)
even?
> (even? 2)
#t
> ((first a) 2)
. . application: not a procedure;
 expected a procedure that can be applied to arguments
  given: even?
  arguments.:

Why is this not working? Isn't ((first a) 2) equivalent to (even? 2) ??

Chase
  • 93
  • 10
  • 1
    Adam B already answered your question, but the question [What is the difference between `quote` and `list`?](https://stackoverflow.com/questions/34984552/what-is-the-difference-between-quote-and-list) can help you understand why. It explains this problem in much greater detail. – Alex Knauth Feb 01 '16 at 22:34

1 Answers1

1

'(even?) is equivalent to (quote (even?)) which returns a list with a symbol even? (not the function).

If you want the code you're describing to work you need to have the first define look like (define a (list even?)) which is a list with the procedure even? in it.

Adam B
  • 3,775
  • 3
  • 32
  • 42