Created
June 29, 2013 22:35
-
-
Save robertoaloi/5892963 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(this_is_fun). | |
-export([have_fun/0]). | |
-export([loop/0]). | |
have_fun() -> | |
table = ets:new(table, [named_table]), | |
F = fun(X) -> X + 1 end, | |
ets:insert(table, {function, F}), | |
register(funny, spawn(?MODULE, loop, [])). | |
loop() -> | |
receive | |
X -> | |
[{function, F}] = ets:lookup(table, function), | |
io:format("~p", [F(X)]) | |
end, | |
loop(). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have the students explain why:
1110
being printed out.