1
(define (layer li)
  (cond ((null? l) li)
        ((null? (cdr li)) (list (car li)))
        (else ((cons (list (car li)) (layer (cdr (li))))))))

This is my code above.

I'm trying to run (layer '(1 2 3))

but I keep getting this error message below. Can anyone tell me what I'm doing wrong? Thanks!

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

Will Ness
  • 70,110
  • 9
  • 98
  • 181
aarondp987
  • 43
  • 4
  • 3
    You have `((` before `cons`, why? – user4003407 Sep 20 '19 at 03:39
  • In most other languages, adding a few parentheses around an expression is either insignificant or a syntax error. Lisp-y languages are different. – molbdnilo Sep 20 '19 at 05:14
  • 2
    `((something argument))` is the same as `something(argument)()` in C languages. Can you imagine what would happen if you add extra `()` in the end of function calls? Also you have undefined variable `l` and you are calling `li` as a function. – Sylwester Sep 20 '19 at 20:49

0 Answers0