<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7036.0">
<TITLE>Adding a list</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">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. </FONT></P>
<P><FONT SIZE=2 FACE="Arial">This is what I have started with and I keep getting an error:</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">(define (doall fn l)</FONT>
<BR><FONT SIZE=2 FACE="Arial"> (if (null? (cdr l)</FONT>
<BR><FONT SIZE=2 FACE="Arial"> (list (fn(car l)))</FONT>
<BR><FONT SIZE=2 FACE="Arial"> (append (process_all fn(cdr l))(list fn(car l))))))</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial">The error is this:</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">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)))))</FONT></P>
<P><FONT SIZE=2 FACE="Arial">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?</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Trista</FONT>
</P>
</BODY>
</HTML>