[plt-scheme] (newbie question) About Loop
On Fri, Jun 12, 2009 at 2:47 AM, MD.MAHBUBUR RASHEED<mmrasheed at gmail.com> wrote:
> Hi,
> How can I implement loop in plt-scheme like in java-
>
> for(int i=0;i<10;){
> for(int j=0;j<3;){
> System.out.println(""+j);
> j++;
> }
> System.out.println(""+i);
> i++;
> }
straightforward, standard and with no intermediary list building:
(do ((i 0 (+ 1 i)))
((>= i 10))
(do ((j 0 (+ 1 j)))
((>= j 3))
(display j)(newline))
(display i)(newline))
do construct is:
(do (inits ...)
(stop? optional-final-exp)
optional-expressions ...)
where one init is (var initial-value update-expression)
as in RNRS...