stepping through a function

Chris Wright <>
Fri Feb 7 01:06:14 CET 2003


I would like to be able to execute a number of functions in a 
"lock-step" way.

Now for the English translation :)


say if have:

------------------------------------
-module(f1).
-export([f1/0]).

f1() ->
     io:format("f1:line 1~n"),
     io:format("f1:line 2~n"),
     io:format("f1:line 3~n").
----------------------------------

and

----------------------------------
-module(f2).
-export([f2/0]).

f2() ->
     io:format("f2:line 1~n"),
     io:format("f2:line 2~n"),
     io:format("f2:line 3~n").

-----------------------------------

What I want to be able to do it put f1 and f2 (and, potentially, the 
even more interesting f3!) in a list and then ask each one to "step" so 
the output would be

f1:line 1
f2:line 1
f1:line 2
f2:line 2
f1:line 3
f2:line 3

A FSM would be one way to do this, but is there another.

This question in motivated, in part, by reading Joe's early paper which 
describes the development of Erlang from Prolog. One of the half way 
points was doing just what I am describing. In about 10 lines of Prolog!

cheers and thanks

chris 




More information about the erlang-questions mailing list