From: david <dav...@ac...> - 2006-01-31 18:10:48
|
I created this function using recursion: (defun sigma-sum (lower upper step) "Sum numbers from lower to upper incrementing the lower by step" (cond ( (> lower upper) 0) (t (+ lower (sigma-sum (+ 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? |