Logo

Programming-Idioms

History of Idiom 2 > diff from v115 to v116

Edit summary for version 116 by def:
New Erlang implementation by user [def]

Version 115

2020-05-18, 15:19:58

Version 116

2020-05-31, 02:55:43

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration
Code
-export([while/1,while/2, start/0]).

while(L) -> while(L,0).
while([], Acc) -> Acc;

while([_|T], Acc) ->
  io:fwrite("~w~n",[Acc]),
  while(T,Acc+1).

start() ->
  X = lists:seq(1,99),
  while(X).