0
votes

I want to get the second value of '(a b c) and I don't want to use cadr. I can get the right answer:

(car (cdr '(a b c)))

'b

But when I built the function:

(define test (lambda (list) (car (cdr (list)))))

(test '(a b c))

. . application: not a procedure; expected a procedure that can be applied to arguments given: '(a b c) arguments...: [none]

I really don't know what's this error mean..

1
In the future, if you have a specific error message, you can often find results in Stack Overflow by searching for that specific error message (and perhaps the language name). For instance, searching for application: not a procedure scheme is:question turns up 121 results. Also, there's no need to include "Scheme" in the title of the question; including it in the tags is sufficient for people looking for Scheme questions to find it.Joshua Taylor

1 Answers

1
votes

There are incorrect parentheses in your code, surrounding the list parameter - in Scheme this: (f) means "apply the f function with no arguments", so in your code this: (list) is trying to invoke the list parameter as if it were a function, which is not, raising an error.

Also notice that it's a bad idea to call list the parameter, there's already a built-in procedure with that name; that's why I renamed it to lst. This should fix it:

(define test
  (lambda (lst)
    (car (cdr lst))))

(test '(a b c))
=> b