[plt-scheme] (newbie question) About Loop

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Fri Jun 12 15:56:40 EDT 2009

> straightforward, standard and with no intermediary list building:
> (do ((i 0 (+ 1 i)))

"do" is standard for now, but I dream that we will someday right that 
wrong.  "do" is a cryptic bit of syntactic sugar that gets in the way of 
refining functional algorithms.

Instead of "do", I suggest using named-"let" unless "map", "for-each", 
folds, etc. fit the problem naturally.

I think that the benefit of avoiding "do" will be more obvious when 
writing idiomatic Scheme code for problems that actually occur in 
nature, not contrived exercises (like, e.g., "do this 7 times for no 
particular reason and with no data being processed").


Posted on the users mailing list.