[plt-scheme] Adding a list
I'm very new to Scheme and need some help. I'm trying to write a function
that accepts an accumulating function(summation, product) and a list of
numbers and returns the accumulation of the operation on each element of the
list. So, if '(1 2 3 4) was supplied to the function and an operation 'sum'
that adds two elements the function would return the sum of the list.
This is what I have started with and I keep getting an error:
(define (doall fn l)
(if (null? (cdr l)
(list (fn(car l)))
(append (process_all fn(cdr l))(list fn(car l))))))
The error is this:
if: bad syntax (has 1 part after keyword) in: (if (null? (cdr l) (list (fn
(car l))) (append (process_all fn (cdr l)) (list fn (car l)))))
I am trying to define the list with this function. I suppose after I can
get it to work, next I will work on the summation, product function. First
I need to get this list function to work. Any ideas?
Trista
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070217/225fec61/attachment.html>