Logo

Programming-Idioms

History of Idiom 78 > diff from v44 to v45

Edit summary for version 45 by elbrujohalcon:
New Erlang implementation by user [elbrujohalcon]

Version 44

2016-04-07, 08:13:37

Version 45

2016-06-02, 03:29:00

Idiom #78 "do while" loop

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

Idiom #78 "do while" loop

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

Code
do_while(Block, C) ->
  case C(Block()) of
    true -> do_while(Block, C);
    false -> ok
  end.
Comments bubble
I'm assuming that C (the condition) has something to do with what happens on Block, therefore C is a predicate with one argument
Demo URL
http://tryerl.seriyps.ru/#id=6df3