Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 763914a6ec
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (36 sloc) 0.904 kB
%% Example1:
%% factorial(25) is assumed to take a long time to compute
%% In the generated module mod1.erl
%% we import the result of the earlier computation
defMods mod1 shell end.
addMod shell.
def fac = fun(0) -> 1; (N) -> N*fac(N-1) end.
120 = fac(5).
F25 = fac(25).
addMod mod1.
def a(N) -> F25 + N end.
addMod shell.
io:format("mod1:a(10)=~p~n",[mod1:a(10)]).
erl2:make_mods().
%% Sample output
%% $./erl2 example1.erl2
%% Created:"gen/exprs.tmp"
%% mod1:a(10)=15511210043330985984000010
%% make_mods saving generated code...
%% Created:"gen/all.gen"
%% Created:gen/mod1.erl
%% Created:gen/shell.erl
%% Success
%% $ cat gen/shell.erl
%% -module(shell).
%% -compile(export_all).
%% fac(0) ->
%% 1;
%% fac(N) ->
%% N * fac(N - 1).
%% $cat gen/mod1.erl
%% -module(mod1).
%% -compile(export_all).
%% a(N) ->
%% F25 = 15511210043330985984000000,
%% F25 + N.
Jump to Line
Something went wrong with that request. Please try again.