Erlang documentation

Lyn A Headley <>
Fri Jul 9 21:39:39 CEST 1999


comparing simple C programs with erlang -- I think that's a good idea.
here's my shot at your example (but I'm pretty new to erlang too!)
anybody else got a more natural solution?

-Lyn

void foo(int x, int y, int z)
{
	if (x > y && y < z)
		/* do something */
	else
	{
	int i;
	for(i = 0; i < z; i++)
		/* do somethong else */
	}
}


foo(X, Y, Z) when X > Y, Y < Z ->
    do_something;

foo(X, Y, Z) ->
    foo_iter(X, Y, Z).

foo_iter(X, Y, 0) ->
    done;

foo_iter(X, Y, Z) ->
    do_something,
    foo(X, Y, Z - 1).




More information about the erlang-questions mailing list