-4
(define function1 (lambda(val)
  (if (list? val) 
     (function2 (val))
     ('!list))))

When I try the input '(t t t), I get the following error:

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

I've defined function2 and it works when I call that on its own, but I'm unable to call it within function1.

Nick is tired
  • 6,860
  • 20
  • 39
  • 51
iii
  • 606
  • 1
  • 6
  • 21
  • 1
    I submitted an edit to clean up your code sample to give it better more lisp-y style. I hope it is accepted. I believe that with cleaner style of code your syntax errors are actually easier to spot. – verdammelt Feb 05 '16 at 04:29
  • 1
    Have a look at (possible duplicate) [“application: not a procedure” in binary arithmetic procedures](http://stackoverflow.com/questions/19022704/application-not-a-procedure-in-binary-arithmetic-procedures). – Joshua Taylor Feb 05 '16 at 16:07
  • 2
    Please don't make more work for other people by vandalizing your posts. By posting on Stack Overflow, you've granted a non-revocable right, under the [CC BY-SA 3.0 license](https://creativecommons.org/licenses/by-sa/3.0) for SO to distribute that content. By SO policy, any vandalism will be reverted. If you want to know more about deleting a post, please take a look at [How does deleting work?](https://meta.stackexchange.com/q/5221) – iBug Feb 11 '19 at 16:42

2 Answers2

5

The problem is that val is not a function. You should replace (function2(val)) with (function2 val).

Furthermore '!list is also not a function; the else clause of the if expression also needs to be corrected.

Tim Jasko
  • 1,532
  • 1
  • 8
  • 12
3

It is '!list and val that are not procedures.

Doug Currie
  • 40,708
  • 1
  • 95
  • 119