[plt-scheme] Adding a list
Please consult your instructor, not us.
But you may wish to check your parenthesis too.
Robby
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
>
>