概要:《Erlang程序设计》第六章中的例子。
hello.erl
-module(hello).
-export([start/0]).
start() ->
io:format("Hello world ~n").
shop.erl
-module(shop).
-export([cost/1]).
cost(oranges) ->
5;
cost(newspaper) ->
8;
cost(apples) ->
2;
cost(pears) ->
9;
cost(milk) ->
7.
makefile
.SUFFIXES: .erl .beam
.erl.beam:
erlc -W $<
ERL = erl -boot start_clean
MODS = hello shop
all: compile
compile: ${MODS:%=%.beam}
@echo "make clean - clean up"
clean:
rm -rf *.beam erl_crash.dump
保存在同一文件夹下。执行:erl -make。编译成功,会出现hello.beam和shop.beam。
参考资料:
《Erlang程序设计》