From: David Hirvonen
Subject: reduce implementation in common lisp
Date: 
Message-ID: <3245DD89.3ED53216@cs.umass.edu>
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
From: Kai Zimmermann
Subject: Re: reduce implementation in common lisp
Date: 
Message-ID: <52b0hu$gse@rzsun02.rrz.uni-hamburg.de>
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