Reputation: 553
I'm just getting started with scheme, and I'm not sure what I'm doing wrong.
(let ((fn (car last-elem))
(output(if (> (length last-elem) 1) ;or = needed?
(cdr last-elem)
( '() ))))
(cond ((equal? fn 'dim) (dim output))
((equal? fn 'print) (print output))
This code is supposed to generate the statement and then pass it through to print, my testing case its Hello, World!
Print right now (it will have more stuff later so I do need a new function) is just this:
(define (print args)
(display(args))
(newline)
This errors out with:
application: not a procedure; expected a procedure that can be applied to arguments given: ("Hello, World!") arguments...: [none] context...:
I think I'm on the write track, because the output I am hoping to get is there in the "given." But I want that to just print.
I know there are a few other questions on SO about this error, but none of their solutions helped me.
Thanks in advance.
Upvotes: 0
Views: 73
Reputation: 236142
For starters, the print
procedure has an extra and incorrect set of parentheses, it should look like this:
(define (print args)
(display args)
(newline))
When you get the "application: not a procedure; expected a procedure" error, it means that you're using parentheses wrong, in Scheme (f)
means that you're trying to apply f
as a no-arguments procedure, if f
is not a procedure then you get the error.
Upvotes: 1