Create a gist now

Instantly share code, notes, and snippets.

@ztj /tryme.erl
Created Jun 14, 2011

Learning Erlang. Counting Pies.
-module(tryme).
-export([main/0]).
loop(A, B, C, D) when B /= D ->
io:fwrite("~s~B~n", [A,B]),
loop(A, C(B), C, D);
loop(A, B, _, _) ->
io:fwrite("~s~B~n", [A, B]),
ok.
inc(B) -> B + 1.
main() -> loop("Pies: ", 10, fun inc/1, 20).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment