From: Pascal Bourguignon <pjb@in...>  20060131 21:00:34

david writes: > I created this function using recursion: > > (defun sigmasum (lower upper step) > "Sum numbers from lower to upper > incrementing the lower by step" > (cond ( (> lower upper) 0) > (t (+ lower > (sigmasum > (+ step lower) > upper step))))) > > it works fine, but I am trying to create a function that can be used for any > problem expressed in sigma notation. Here is that attempt: > (defun sigma (opr lower upper step) > "Operate on numbers using process defined > by sigma notation." > (cond ( (> lower upper) 0) > (t ((apply opr lower > (sigma > (apply opr step lower) > upper step)))))) > > and here is how I call the function: > (sigma '+ 1 4 1) > > but it does not work. Any advice? What is the meaning of this form? ((apply opr lower (sigma (apply opr step lower) upper step))) This is not valid Common Lisp syntax. The CAR of a form can only be either:  a symbol denoting the function, the macro or the special operator named by this symbol, or:  a list of the form (lambda arguments . body), denoting the corresponding anonymous function. nothing else. Your intended definition of sigma is wrong. Try it with (function *) and step = 1.0.  __Pascal Bourguignon__ http://www.informatimago.com/ Nobody can fix the economy. Nobody can be trusted with their finger on the button. Nobody's perfect. VOTE FOR NOBODY. 