This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

function call: expected a function after the open parenthesi

3 posts · 4000 views

(define (paint d r) (if (empty? d) null (if (empty? r) null (
                                             (list
                                         (first d) (first r))                       
                                         (paint (rest d) (rest r))
                                        )
                                        )))

(paint (list 1 2 3 4) (list 1 2 3))
I'm run this script and take that error:
function call: expected a function after the open parenthesis, but received (list 3 3)

Re: function call: expected a function after the open parent

Ive just made a SO Q&A that answers this question.
The part of the text that is most suitable for your case:

Trying to group expressions or create a block
(if (< a b)
    ((proc1)
     (proc2))
    #f)
When the predicate/test is true Scheme assumes will try to evaluate both (proc1) and (proc2) then it will call the result of (proc1) because of the parentheses. To create a block in Scheme you use begin:
(if (< a b)
    (begin 
      (proc1)
      (proc2))
    #f)
In this (proc1) is called just for effect and the result of teh form will be the result of the last expression (proc2).
I'm the author of two useless languages that uses BF as target machine.
Currently I'm planning a Scheme compiler :p

Re: function call: expected a function after the open parent

sylwester wrote:Ive just made a SO Q&A that answers this question.
The part of the text that is most suitable for your case:

Trying to group expressions or create a block
(if (< a b)
    ((proc1)
     (proc2))
    #f)
When the predicate/test is true Scheme assumes will try to evaluate both (proc1) and (proc2) then it will call the result of (proc1) because of the parentheses. To create a block in Scheme you use begin:
(if (< a b)
    (begin 
      (proc1)
      (proc2))
    #f)
In this (proc1) is called just for effect and the result of teh form will be the result of the last expression (proc2).
Thanks for help :D