[plt-scheme] Adding a list

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Feb 17 17:03:02 EST 2007

On Feb 17, 2007, at 4:02 PM, Carl Eastlund wrote:

> Teresa, I suggest you open your file in DrScheme, select that
> function, and run "Reindent" from the "Scheme" menu.  In general, when
> you see an error about an expression having the wrong number of parts,
> you have parentheses in the wrong place.  Reindenting works based on
> the parentheses, and will probably make your error clear.

And once you have done that and fixed your names, too, you'll get

    > (doall + '(1 2 3))
   (3 #<primitive:+> 2 #<primitive:+> 1)

which is not what you want.

Take a look at htdp.org That may help.

-- Matthias

> --Carl
> On 2/17/07, Teresa Stanton <tms43 at clearwire.net> wrote:
>> 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
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.