I am reading SICP recently to learn lisp programming.
There is an example in the book to make a high level function sum as below.
(define (sum term a next b)
...
(term a)
...
(next a)
...
In this function, term and next are functions.
I want to write the same function in elisp like this.
(defun sum (term a next b)
....
(funcall term a)
...
(func next a)
....
Then I define some test functions to test sum
(defun inc-test (x) (+ x 1))
sum inc-test 1 inc-test 10
but it show errors like this: Invalid function: inc-test
As I am new to elisp, can anyone call tell me how to fix it? very appreciate
sum
?inc-test
in your last example is used as a variable, but is not defined as a variable (it is a function). You need to pass either a symbol or a function reference tofuncall
. Hence one way of fixing your code is to pass it'inc-test
instead ofinc-test
(note the quote).