I am having problems with a scheme function.
(define myfun(operator lis)
(if(null? lis)
'()
(cons(operator (car lis)(car lis))myfun(operator (cdr lis))
))))
The function takes an operator as an parameter and a list for example (+'(1 2 3 4))
and the error i get when i try to call the function is : expecting a number but received a list. So my question is how do i call a function recursively with an operator and a list?
UPDATE: just needed a ' sign before the operator.
Just pass
+to the function, without any quoting.+denotes the addition function.will perform