You didn't provide enough information in the question to give a precise answer. Oh well - just for fun, let's see how to solve this using streams. The following will work under R5RS, assuming that you have SRFI-41 installed:
; import streams library
(#%require srfi/41)
; generate an infinite stream of numbers
; starting at x, with an n increment
(define (iter x n)
(stream-cons x (iter (+ x n) n)))
; compute the sum of the first n even numbers
(define (sum-even n)
(let loop ((evens (iter 0 2)) ; stream of even numbers
(acc 0) ; accumulated sum
(n n)) ; generate n numbers
(if (zero? n) ; did we generate enough numbers?
acc ; then return the accumulator
(loop (stream-cdr evens) ; else advance recursion
(+ acc (stream-car evens)) ; update accumulator
(- n 1))))) ; one less number to generate
You didn't provide enough information in the question to give a precise answer. Oh well - just for fun, let's see how to solve this using streams. The following will work under R5RS, assuming that you have SRFI-41 installed:
It works as expected: