erlang Pred = fun (X) -> X < 150 end,
Action = fun (X) -> io:format("~B,", [X]), X * 2 end,
X = 1,
while_do(Pred, Action, X).
-module(while_do).
-export([start/0]).
start() ->
Pred = fun (X) -> X < 150 end,
Action = fun (X) -> io:format("~B,", [X]), X * 2 end,
X = 1,
while_do(Pred, Action, X).
while_do(Pred, Action, State) -> Cond = Pred(State), if Cond -> begin NewState = Action(State), while_do(Pred, Action, NewState) end ; true -> true end.