lispers,
i'm trying to implement the reduce function in lisp.
it looks like this in scheme:
(define (reduce f acc base l)
(if (null? l) base
(acc (f (car l)) (reduce f acc base (cdr l)))))
i can't seem to get the parameter/function passing to
work properly. any help is much appreciated.
david hirvonen
···············@cs.umass.edu
David Hirvonen (········@cs.umass.edu) wrote:
: i'm trying to implement the reduce function in lisp.
: it looks like this in scheme:
: (define (reduce f acc base l)
: (if (null? l) base
: (acc (f (car l)) (reduce f acc base (cdr l)))))
: i can't seem to get the parameter/function passing to
: work properly. any help is much appreciated.
Hi,
I checked and you seem to post from an undergrad account. Since I don't know
wether you need this for a CS course your taking, I won't post the complete
solution, just two hints ;-)
1) Commonlisp's handling of function definition and calling
differs from Scheme's
2) Check out the documentation for defun, funcall, and apply
The changes you have to make to the above code fragment
are pretty much straight forward.
You're welcome,
Kai