954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need help with a LISP function(DrScheme)

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)))
)
lotrsimp12345
Posting Pro in Training
413 posts since Jun 2009
Reputation Points: 47
Solved Threads: 2
 

Did you mean to post this in CompSci?

jonsca
Quantitative Phrenologist
Team Colleague
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
 

yea my bad.

lotrsimp12345
Posting Pro in Training
413 posts since Jun 2009
Reputation Points: 47
Solved Threads: 2
 

Moved...

WaltP
Posting Sage w/ dash of thyme
Moderator
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

delete one of the threads since i posted it here. doesn't matter which one.

lotrsimp12345
Posting Pro in Training
413 posts since Jun 2009
Reputation Points: 47
Solved Threads: 2
 

some one please help I am really confused!! :(

lotrsimp12345
Posting Pro in Training
413 posts since Jun 2009
Reputation Points: 47
Solved Threads: 2
 

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

davibq
Newbie Poster
5 posts since May 2010
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You