Logo

Programming-Idioms

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

Idiom #78 "do while" loop

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

do_while(Block, C) ->
  case C(Block()) of
    true -> do_while(Block, C);
    false -> ok
  end.

I'm assuming that C (the condition) has something to do with what happens on Block, therefore C is a predicate with one argument
loop
   stuff();
   if not c then
      exit;
   end if;
end loop;

New implementation...
< >
deleplace