0

I can write the recursion version correctly need help with writing a do loop in DrScheme.

After the do loop the variable x is sent to car L intially and then is updated to first element of everything but first element in list.

(define (sumiteration L)
  (do ((x (car L) (car(cdr L))))
    ((null? L))
    (set! sum (+ sum x)))
)
4
Contributors
6
Replies
8
Views
7 Years
Discussion Span
Last Post by davibq
-1

(define (sumiteration L)
(do ((sum 0)
)
((null? L) suma)
(set! sum (+ sum (car L)))
(set! L (cdr L))
)
)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.