Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #78 "do while" loop

Execute a block once, then execute it again as long as boolean condition c is true.

do {
  someThing();
  someOtherThing();
} while(c);
loop
   stuff();
   if not c then
      exit;
   end if;
end loop;
do {
	someThing();
	someOtherThing();
} while(c);
do
{
  stuff()
} while ( c ) ;
(loop []
  (do something)
  (when c
    (recur)))
IDENTIFICATION DIVISION.
PROGRAM-ID. "do while" loop.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 boolean-c    PIC x.
   88 c-true    PIC x VALUE 't'.
   88 c-false   PIC x VALUE 'f'.
PROCEDURE DIVISION.
    PERFORM WITH TEST AFTER UNTIL c-false
       PERFORM somthing
    END-PERFORM   
STOP RUN.
do {
  someThing();
  someOtherThing();
} while(c);
do
{
    stuff();
} while(c);
do
{
    something;
    somethingElse;
}
while (c);
def main(condition) do
  case condition do
    true -> main(condition)
    false -> nil
  end
end
do_while(Block, C) ->
  case C(Block()) of
    true -> do_while(Block, C);
    false -> ok
  end.
do
  call do_something
  if (.not. c) exit
end do
for{
   someThing()
   someOtherThing()
   if !c {
     break
   }
}
for done := false; !done; {
	someThing()
	someOtherThing()
	done = !c()
}
doowhile c b = do a <- b; if c a
                          then doowhile c b
                          else return a

doowhile (=="") getLine
gg
do {
   something();
} while (c);
do {
	someThing();
	someOtherThing();
} while(c);
(loop do (something)
      while c)
repeat
	someThing()
	someOtherThing()
until not c
do ... while(c);
do {
    echo '.';
} while ($c);
repeat
  Something;
  SomethingElse;
until not c;
repeat
  Something;
  SomethingElse;
until
  c;
do {
    doSomeStuff();
} while(c);
while True:
    do_something()
    if not c:
        break
begin
  # code
end while c
while {
   doStuff();
   c
} { /* EMPTY */ }
loop {
    doStuff();
    if !c { break; }
}
do {
  someThing()
  someOtherThing()
} while (c)
[
    " do something "
    c
] whileTrue: [].
Do 
    SomeThing()
    SomeOtherThing()
Loop While c

New implementation...
< >
deleplace